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

SIGSEGV while compiling when trying to instantiate a case type, that uses an enum with non-zero start #11585

noonien opened this issue Jun 25, 2019 · 1 comment


Copy link

commented Jun 25, 2019

The compiler produces a SIGSEGV when trying to compile a file that has a case type, that switches on an enum that does not have a 0 start value


  FooKind = enum
    fkBar = 1 # if this would be 0, the SIGSEGV would not occur

  Foo = object
    case kind*: FooKind
    of fkBar: bar*: int

Foo(hello: 0)

Current Output

Traceback from system (most recent call last)
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

Expected Output

Error: undeclared field: 'hello'

Possible Solution

Additional Information

$ nim -v
Nim Compiler Version 0.20.99 [Linux: amd64]
Compiled at 2019-06-15
Copyright (c) 2006-2019 by Andreas Rumpf

active boot switches: -d:release -d:nativeStackTrace

This is 2019-06-25-devel-0d50b0c nightly build.


This comment has been minimized.

Copy link

commented Jun 25, 2019

To possibly save someone some time:
The bug is here:
That val should be a valid val of the enum/range, or do something else if 0 is invalid. The first option may not be strictly correct though because of zero init.

@Araq Araq closed this in 045eeab Jul 3, 2019

narimiran added a commit that referenced this issue Jul 8, 2019

fixes #11585
(cherry picked from commit 045eeab)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.