rascal
rascal copied to clipboard
Indexed field assignment on parse trees
You can access parts of a parse tree using indexing, but you cannot assign subtrees using the same method:
module bug::IndexedFieldAssignment
syntax S = A "$";
syntax A = "a" | "A";
import ParseTree;
import IO;
test bool testIndexedFieldAssignment() {
S s = parse(#S, "a$");
value a = s[0];
assert "<a>" == "a";
s[0] = (A)`A`;
return "<s>" == "A$";
}
The assertion succeeds but the test fails with an error:
Unsupported subscript of type int on type S
Advice: |https://www.rascal-mpl.org/docs/Rascal/Errors/CompileTimeErrors/UnsupportedSubscript|
For the sake of consistency and usefulness of this feature, I think indexed assignment should be supported.