rascal icon indicating copy to clipboard operation
rascal copied to clipboard

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

Open jurgenvinju opened this issue 3 years ago • 1 comments

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 avatar Mar 10 '23 11:03 jurgenvinju

@PaulKlint how does the generated code handle this case?

jurgenvinju avatar Mar 10 '23 11:03 jurgenvinju