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

unhelpful error message when using [N: int] instead of [N: static[int]] in generic #17362

Closed
ShadowElf37 opened this issue Mar 13, 2021 · 2 comments · Fixed by #20529
Closed

Comments

@ShadowElf37
Copy link

This error message is particularly confusing for beginners, who may forget or simply not know to put static. Getting compiler noise makes it impossible to determine what the actual issue is with the code.

Error

fatal.nim(53)            sysFatal
Error: unhandled exception: int128.nim(72, 11) `arg.sdata(2) == 0` out of range [AssertionDefect]

Expected Output

test.nim(4)            test
Error: unhandled exception: Please put static thank you. [AssertionDefect]

Sample Bad Code

type IntArrayContainer[N: int] = object
    arr: array[N, int]

discard IntArrayContainer[3]()

Version

Nim Compiler Version 1.4.4 [MacOSX: arm64]
Compiled at 2021-02-24
Copyright (c) 2006-2020 by Andreas Rumpf
@timotheecour
Copy link
Member

PR welcome

@konsumlamm
Copy link
Contributor

This is an internal assertion failure, which shouldn't occur in the first place, there should be a normal Nim error message instead. So changing the assertion message wouldn't fix the actual issue.

Duplicates:
#17163
#15862
#6834

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.

3 participants