-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Compiler crash with invalid object variant #12379
Comments
They are also supported with bool and ints/uints below size of 32 |
…m-lang#12379 (nim-lang#12444) (cherry picked from commit 81125e2)
Doesn't seem to be fixed. |
Please also allow booleans as discriminator (didn't check lately but it used to work) |
This snippet is supposed to work afaict, since the error messages in semobjconstr and the tests for discriminators seem to indicate that: EDIT: OTOH the error here seems to stem from the fact that the backend still generates those checks and those checks rely on the size being <= 16 bits.. afaict |
As this crashes: type
E = enum
a = 1
b = high(int32)
Cobj = object
case a: E
of a:
b: bool
bb: bool
of b:
i: int
u: uint
var t = Cobj(a: E.a)
t.b = true
echo t and this: type
E = enum
c = 0
a = 1
b = high(int32)
Cobj = object
case a: E
of a:
b: bool
bb: bool
of b:
i: int
u: uint
else:
uuu: uint8
var t = Cobj(a: E.a)
t.b = true
echo t both hang up gcc(??). I think size > 16bits is just not supported. |
(cherry picked from commit cf5c3f2)
The following snippets should provide a better error, saying that object variants/case objects are only supported with enums as discriminators.
Example
Current Output
Changing the discriminators type to
int32
traps the compiler in an infinite loop.Additional Information
The text was updated successfully, but these errors were encountered: