chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.78k stars 418 forks source link

Using a non-param value in an enum can cause an internal error #22307

Open jabraham17 opened 1 year ago

jabraham17 commented 1 year ago

Summary of Problem

Using a non-param value as the initializer for an enum value is an error, but doing so with a more complicated expression is not checked and results in an internal error.

Steps to Reproduce

Source Code:

proc foo() /*param*/ do return 1;
enum A {
  a=foo()+1, // without the +1, correctly gives user an error that expression is not a param value
}

Compile command: chpl test.chpl

Output

test.chpl:2: internal error: RES-CAL-NFO-0090 chpl version 1.31.0 pre-release (2048f5ab31)
Note: This source location is a guess.

Internal errors indicate a bug in the Chapel compiler,
and we're sorry for the hassle.  We would appreciate your reporting this bug --
please see https://chapel-lang.org/bugs.html for instructions.  In the meantime,
the filename + line number above may be useful in working around the issue.

Configuration Information

DanilaFe commented 2 months ago

The issue here is that we skip normalizing the definitions of enum constant values. I tried performing normalization, but this does not seem to go well (though, I may have just not tried hard enough! 😄 ). Another thought was to try skipping the assertion for normalization if defining an EnumSymbol, but that seemed like a needless special case.