rascal
rascal copied to clipboard
`type` constructor doesn't accept keyword parameters starting with `\` symbol
Describe the bug
When constructing a type using type constructor with a type definition that contains keyword parameters that start with the symbol \, I get the exception: io.usethesource.vallang.exceptions.IllegalIdentifierException: \val is not a valid identifier
(it happens only for keyword parameters, and the actual name after the \ symbol doesn't matter)
To Reproduce
module Main
import IO;
import Type;
int main(int testArgument=0) {
Symbol litAdt = adt("Literal", []);
Production litProd = choice(litAdt, {cons(label("Literal", litAdt), [], [label("\\val", \int())], {})});
type[value] litType = type(litAdt, (litAdt : litProd));
println(litType);
return testArgument;
}
Expected behavior
The type constructor is expected to construct a valid type[value] variable.
Stack trace
io.usethesource.vallang.exceptions.IllegalIdentifierException: \val is not a valid identifier
(internal error)
at $shell$(|main://$shell$|)
io.usethesource.vallang.exceptions.IllegalIdentifierException: \val is not a valid identifier
at io.usethesource.vallang.type.TypeStore.declareKeywordParameter(TypeStore.java:645)
at io.usethesource.vallang.type.ConstructorType$Info.fromProduction(ConstructorType.java:121)
at io.usethesource.vallang.type.AbstractDataType$Info.fromSymbol(AbstractDataType.java:126)
at io.usethesource.vallang.type.TypeFactory$TypeValues.fromSymbol(TypeFactory.java:1111)
at io.usethesource.vallang.type.TypeFactory.fromSymbol(TypeFactory.java:732)
at org.rascalmpl.types.TypeReifier.symbolToType(TypeReifier.java:206)
at org.rascalmpl.values.RascalValueFactory.reifiedType(RascalValueFactory.java:389)
at org.rascalmpl.semantics.dynamic.Expression$ReifiedType.interpret(Expression.java:2328)
at org.rascalmpl.semantics.dynamic.Declarator$Default.interpret(Declarator.java:52)
at org.rascalmpl.semantics.dynamic.LocalVariableDeclaration$Default.interpret(LocalVariableDeclaration.java:36)
at org.rascalmpl.semantics.dynamic.Statement$VariableDeclaration.interpret(Statement.java:1003)
at org.rascalmpl.interpreter.result.RascalFunction.runBody(RascalFunction.java:384)
at org.rascalmpl.interpreter.result.RascalFunction.call(RascalFunction.java:293)
at org.rascalmpl.semantics.dynamic.Expression$CallOrTree.interpret(Expression.java:540)
at org.rascalmpl.semantics.dynamic.Command$Expression.interpret(Command.java:61)
at org.rascalmpl.interpreter.Evaluator.eval(Evaluator.java:1094)
at org.rascalmpl.interpreter.Evaluator.eval(Evaluator.java:955)
at org.rascalmpl.interpreter.Evaluator.eval(Evaluator.java:908)
at org.rascalmpl.repl.RascalInterpreterREPL.evalStatement(RascalInterpreterREPL.java:132)
at org.rascalmpl.vscode.lsp.terminal.LSPTerminalREPL$1.evalStatement(LSPTerminalREPL.java:168)
at org.rascalmpl.repl.BaseRascalREPL.handleInput(BaseRascalREPL.java:106)
at org.rascalmpl.vscode.lsp.terminal.LSPTerminalREPL$1.handleInput(LSPTerminalREPL.java:281)
at org.rascalmpl.repl.BaseREPL.handleInput(BaseREPL.java:180)
at org.rascalmpl.repl.BaseREPL.run(BaseREPL.java:347)
at org.rascalmpl.vscode.lsp.terminal.LSPTerminalREPL.main(LSPTerminalREPL.java:363)