Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing compiler error when static missing in generic #15862

Closed
n5m opened this issue Nov 6, 2020 · 0 comments · Fixed by #20529
Closed

Confusing compiler error when static missing in generic #15862

n5m opened this issue Nov 6, 2020 · 0 comments · Fixed by #20529

Comments

@n5m
Copy link
Contributor

n5m commented Nov 6, 2020

Current Output

Compiling the following file fails and produces an unhelpful error.

# mvp.nim
type ArrayBlock[I, T] = object
  data*: array[I, T]

var s: ArrayBlock[30, int]
user@user:~$ nim c mvp.nim 
Hint: used config file '/home/user/nim/config/nim.cfg' [Conf]
Hint: used config file '/home/user/nim/config/config.nims' [Conf]
....fatal.nim(49)            sysFatal
Error: unhandled exception: int128.nim(72, 11) `arg.sdata(2) == 0` out of range [AssertionDefect]

Changing the type definition to

type ArrayBlock[I: static[Natural], T]

removes the compilation error, but the error message does not suggest that.

Additional Information

git hash: fa5f225

user@user:~$ nim -v
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2020-11-06
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: fa5f225efc7161110b0d4cf57e86646f2b0d97f8
active boot switches: -d:release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants