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
400 stars 77 forks source link

Accessing the arguments of a lexical Tree node leaks an internal error #1528

Open rodinaarssen opened 3 years ago

rodinaarssen commented 3 years ago

Describe the bug

Accessing the arguments of a lexical Tree node leaks an internal error, instead of returning gracefully.

To Reproduce

rascal>lexical A = [a]+;
ok
rascal>(A)`a`[0]
org.rascalmpl.exceptions.ImplementationError: Unexpected error in Rascal interpreter: This is not a context-free production: appl(prod(lex("A"),[iter(\char-class([range(97,97)]))],{}),[appl(regular(iter(\char-class([range(97,97)]))),[char(97)],loc=|prompt:///|(4,1))],src=|prompt:///|(4,1))
(internal error)
        at $root$(|main://$root$|)

org.rascalmpl.exceptions.ImplementationError: Unexpected error in Rascal interpreter: This is not a context-free production: appl(prod(lex("A"),[iter(\char-class([range(97,97)]))],{}),[appl(regular(iter(\char-class([range(97,97)]))),[char(97)],loc=|prompt:///|(4,1))],src=|prompt:///|(4,1))
        at org.rascalmpl.values.parsetrees.TreeAdapter.getASTArgs(TreeAdapter.java:393)
        at org.rascalmpl.interpreter.result.ConcreteSyntaxResult.subscript(ConcreteSyntaxResult.java:69)
        at org.rascalmpl.semantics.dynamic.Expression$Subscript.interpret(Expression.java:2608)
        at org.rascalmpl.semantics.dynamic.Command$Expression.interpret(Command.java:61)
        at org.rascalmpl.interpreter.Evaluator.eval(Evaluator.java:1125)
        at org.rascalmpl.interpreter.Evaluator.eval(Evaluator.java:995)
        at org.rascalmpl.interpreter.Evaluator.eval(Evaluator.java:950)
        at org.rascalmpl.repl.RascalInterpreterREPL.evalStatement(RascalInterpreterREPL.java:131)
        at org.rascalmpl.eclipse.repl.RascalTerminalConnector$2.evalStatement(RascalTerminalConnector.java:342)
        at org.rascalmpl.repl.BaseRascalREPL.handleInput(BaseRascalREPL.java:106)
        at org.rascalmpl.eclipse.repl.RascalTerminalConnector$2.handleInput(RascalTerminalConnector.java:297)
        at org.rascalmpl.repl.BaseREPL.handleInput(BaseREPL.java:180)
        at org.rascalmpl.repl.BaseREPL.run(BaseREPL.java:347)
        at org.rascalmpl.eclipse.repl.RascalTerminalConnector$1.run(RascalTerminalConnector.java:137)

ok

Expected behavior A clear and concise description of what you expected to happen.

Desktop (please complete the following information):

PaulKlint commented 3 years ago

I added the interpreter label, since the compiler handles this as expected.

PaulKlint commented 3 years ago

We have already tests for this case in lang::rascal::tests::concrete::SubscriptAndSlice but these are currently ignored for the interpreter.