Casting an enum element with explicit element types to the element type results in a compilation error in some cases.
Source Code:
The following enum snippet fails to compile:
enum Numbers {one=1:int(64), two};
writeln(Numbers.one: int(64)); // error here
The error is from type.cpp line 260:
// We think that all params should have init values by now.
INT_ASSERT(sym && !sym->symbol()->hasFlag(FLAG_PARAM));
Interestingly, this snippet, which has a slightly altered code path, succeeds in compiling and executing as expected:
type t = int(64);
enum Numbers {one=1:t, two};
writeln(Numbers.one: t); // prints '1'
Associated Future Test(s):
test/types/enum/typed.chpl #6207
chpl --version: chpl Version 1.14.0.8dc84bdI'm going to grab this one next, assuming no one has claimed it
The internal error is due to failing to recognize that the initial value for the first enum constant is a CallExpr (specifically, a call to a _cast function). Interestingly, removing the explicit size for the int causes the program to work - we only seem to have issues with ints, uints, etc. that involve an explicit size rather than relying on Chapel's default. Still investigating
Most helpful comment
I'm going to grab this one next, assuming no one has claimed it