usethesource / rascal

The implementation of the Rascal meta-programming language (including interpreter, type checker, parser generator, compiler and JVM based run-time system)
http://www.rascal-mpl.org
Other
406 stars 78 forks source link

"UndeclaredVariable" when assigning into a unset keyword field of a ADT constructor #1780

Open jurgenvinju opened 1 year ago

jurgenvinju commented 1 year ago

Describe the bug

>rascal>data X = x(map[str,str] namen=());
ok
rascal>X example = x();
X: x()
rascal>example.namen["jurgen"] = "vinju";
|prompt:///|(0,13,<1,0>,<1,13>): Uninitialized variable
Advice: |https://www.rascal-mpl.org/docs/Rascal/Errors/CompileTimeErrors/UninitializedVariable/UninitializedVariable.html|

This makes little sense to me. I expected the example.namen to produce the empty map by the default definition, then setting the key "jurgen" to "vinju", then assigning the new map into example.namen, then returning the new example value.

jurgenvinju commented 1 year ago

@PaulKlint how does the generated code handle this case?