Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rascal Shell stacktrace differs between repl and command line execution #1429

Open
Tillaert opened this issue Jul 23, 2020 · 0 comments
Open
Labels

Comments

@Tillaert
Copy link

Describe the bug

When printing out a stack trace, in the event a Rascal program terminates with an exception being thrown, the stacktrace of Rascal Shell (executed directly from the command line) differs from the stacktrace of the console/repl.

To Reproduce

Steps to reproduce the behavior:

Given a small test program:

module TE

import IO;

int f2(int i) {
	throw "Intentional Error";
}

void main(str args = [])
{
	println(f2(1138));
}

Executing it from the repl, gives this stac trace:

PS C:\Users\Tillaert\projects\test\src> java -jar C:\Users\Tillaert\Downloads\rascal-0.18.2.jar
Version: 0.18.2
INFO: detected |lib://rascal| at |jar+file:///C:/Users/Tillaert/Downloads/rascal-0.18.2.jar!/|
rascal>import TE;
Loading module |file:///C:/Users/Tillaert/projects/test/src/TE.rsc|
INFO: resolved |lib://rascal| at |jar+file:///C:/Users/Tillaert/Downloads/rascal-0.18.2.jar!/|
Loading module |lib://rascal/IO.rsc|
Loading module |lib://rascal/Exception.rsc|
ok
rascal>main();
|file:///C:/Users/Tillaert/projects/test/src/TE.rsc|(51,19,<6,7>,<6,26>): "Intentional Error"
        at f2(|file:///C:/Users/Tillaert/projects/test/src/TE.rsc|(27,47,<5,0>,<7,1>))
        at main(|file:///C:/Users/Tillaert/projects/test/src/TE.rsc|(111,18,<11,1>,<11,19>))
        at $shell$(|prompt:///|(0,7,<1,0>,<1,7>)ok
rascal>

However, when executing the rascal code directly from the command line, the Rascal stacktrace is truncated (only showing the error) and a Java stack trace is shown instead:

PS C:\Users\Tillaert\projects\test\src> java -jar C:\Users\Tillaert\Downloads\rascal-0.18.2.jar TE.rsc
Version: 0.18.2
INFO: detected |lib://rascal| at |jar+file:///C:/Users/Tillaert/Downloads/rascal-0.18.2.jar!/|
INFO: resolved |lib://rascal| at |jar+file:///C:/Users/Tillaert/Downloads/rascal-0.18.2.jar!/|


unexpected error: /C:/Users/Tillaert/projects/test/src/TE.rsc:6,7: "Intentional Error"
org.rascalmpl.interpreter.control_exceptions.Throw: /C:/Users/Tillaert/projects/test/src/TE.rsc:6,7: "Intentional Error"
        at org.rascalmpl.interpreter.control_exceptions.ControlException.reallyFillInStackTrace(ControlException.java:42)
        at org.rascalmpl.interpreter.control_exceptions.Throw.fillInStackTrace(Throw.java:138)
        at java.lang.Throwable.<init>(Throwable.java:265)
        at java.lang.Exception.<init>(Exception.java:66)
        at java.lang.RuntimeException.<init>(RuntimeException.java:62)
        at org.rascalmpl.interpreter.control_exceptions.ControlException.<init>(ControlException.java:25)
        at org.rascalmpl.interpreter.control_exceptions.Throw.<init>(Throw.java:73)
        at org.rascalmpl.interpreter.control_exceptions.Throw.<init>(Throw.java:93)
        at org.rascalmpl.semantics.dynamic.Statement$Throw.interpret(Statement.java:920)
        at org.rascalmpl.interpreter.result.RascalFunction.runBody(RascalFunction.java:400)
        at org.rascalmpl.interpreter.result.RascalFunction.call(RascalFunction.java:333)
        at org.rascalmpl.semantics.dynamic.Expression$CallOrTree.interpret(Expression.java:533)
        at org.rascalmpl.semantics.dynamic.Expression$CallOrTree.interpret(Expression.java:495)
        at org.rascalmpl.semantics.dynamic.Statement$Expression.interpret(Statement.java:365)
        at org.rascalmpl.interpreter.result.RascalFunction.runBody(RascalFunction.java:400)
        at org.rascalmpl.interpreter.result.RascalFunction.call(RascalFunction.java:297)
        at org.rascalmpl.interpreter.result.AbstractFunction.call(AbstractFunction.java:207)
        at org.rascalmpl.interpreter.Evaluator.main(Evaluator.java:592)
        at org.rascalmpl.shell.ModuleRunner.run(ModuleRunner.java:33)
        at org.rascalmpl.shell.RascalShell.main(RascalShell.java:93)

Expected behavior

I would expect that, at least the complete rascal stack trace would be displayed. It would be nice, when no error occurs in the Java code itself, no Java stack trace is displayed (this adds noise to the output). The rascal runtime should still exit with a non-zero exit code.

@Tillaert Tillaert added the bug label Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant