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

PanicSentinel value isn't propagated via Vector & co. #7245

Closed
jdunkerley opened this issue Jul 10, 2023 · 7 comments · Fixed by #7385
Closed

PanicSentinel value isn't propagated via Vector & co. #7245

jdunkerley opened this issue Jul 10, 2023 · 7 comments · Fixed by #7385
Assignees
Labels
Milestone

Comments

@jdunkerley
Copy link
Member

image

If the user enters some invalid code within a Vector, this results in only an "Execution failed" and no way to find the error.

@JaroslavTulach
Copy link
Member

JaroslavTulach commented Jul 19, 2023

When I have t.enso file with:

from Standard.Base import all

main = [1, 2, 3, Decimal.nan ]

I can run it and see reasonable error:

sbt:enso> runEngineDistribution --run t.enso
Execution finished with an error: Method `nan` of type Decimal.type could not be found.
        at <enso> t.main(t.enso:3:18-28)

e.g. from a CLI perspective things are looking fine.

@JaroslavTulach
Copy link
Member

The IDE converts the execution error cause by Decimal.nan into PanicSentinel according to its documentation:

This tracing is enabled by the active intervention of the runtime instrumentation, and does
not function in textual mode.

This tracing isn't going to happen in the CLI - only IdExecutionInstrument does the conversion.

However PanicSentinel isn't a warning - e.g. it doesn't get propagated further...

@JaroslavTulach
Copy link
Member

JaroslavTulach commented Jul 19, 2023

What is the desired behavior? Shall we treat PanicSentinel as a Warning and propagate it like that? I can easily achieve

treat PanicSentinel as warning

with following few lines change:

diff --git engine/runtime-instrument-id-execution/src/main/java/org/enso/interpreter/instrument/IdExecutionInstrument.java engine/runtime-instrument-id-execution/src/main/java/org/enso/interpreter/instrument/IdExecutionInstrument.java
index c868592d51..a710420955 100644
--- engine/runtime-instrument-id-execution/src/main/java/org/enso/interpreter/instrument/IdExecutionInstrument.java
+++ engine/runtime-instrument-id-execution/src/main/java/org/enso/interpreter/instrument/IdExecutionInstrument.java
@@ -244,7 +248,10 @@ public class IdExecutionInstrument extends TruffleInstrument implements IdExecut
       if (exception instanceof TailCallException) {
         onTailCallReturn(exception, Function.ArgumentsHelper.getState(frame.getArguments()));
       } else if (exception instanceof PanicException panicException) {
-        onReturnValue(frame, new PanicSentinel(panicException, context.getInstrumentedNode()));
+        var ctx = EnsoContext.get(context.getInstrumentedNode());
+        var sentinel = new PanicSentinel(panicException, context.getInstrumentedNode());
+        var warning = Warning.create(ctx, panicException.getMessage(), context.getInstrumentedNode());
+        onReturnValue(frame, WithWarnings.appendTo(ctx, sentinel, warning));
       } else if (exception instanceof AbstractTruffleException) {
         onReturnValue(frame, exception);
       }

Would you consider that a fix, @jdunkerley? Probably not as I now can see that I changed the red border to orange one. If that is a problem (which I expect), then we need something slightly better:

  • duplicate the treatment of WithWarnings everywhere to also deal with PanicSentinel
  • also check the payload of WithWarnings in the language server and send message that will red border the nodes

CCing @4e6

@JaroslavTulach JaroslavTulach changed the title Errors in a Vector result only in an Execution failed message and no details. PanicSentinel value isn't propagated via Vector & co. Jul 19, 2023
@JaroslavTulach JaroslavTulach moved this from 📤 Backlog to ⚙️ Design in Issues Board Jul 19, 2023
@JaroslavTulach JaroslavTulach moved this from ⚙️ Design to 👁️ Code review in Issues Board Jul 25, 2023
@JaroslavTulach
Copy link
Member

JaroslavTulach commented Jul 25, 2023

The #7385 pull request shows a conservative approach that just turns PanicSentinel into an object that has WarningsLibrary.hasWarnings(...). The more radical change is shown at jtulach/NoPanicSentinel branch - it removes PanicSentinel altogether - but then we'd have to fix a lot of Runtime*Tests. CCing @4e6. A sample difference for example is:

List(Response(Some(0823c808-30ab-44bd-9e80-3c0cf7f32166), PushContextResponse(55b911ed-f384-460a-9410-da16d121085b)), Response(None, ExecutionUpdate(55b911ed-f384-460a-9410-da16d121085b, List(Diagnostic(Error, Some("The name `undefined` could not be found."), Some(/tmp/enso-test-packages2956044925097422099/src/Main.enso), Some(Range(Position(2, 8), Position(2, 17))), Some(c75803f2-3fb3-426f-bb8a-c7bbec6cae3a), Vector())))), Response(None, ExpressionUpdates(55b911ed-f384-460a-9410-da16d121085b, Set(ExpressionUpdate(c75803f2-3fb3-426f-bb8a-c7bbec6cae3a, Some("Standard.Builtins.Main.Panic"), None, Vector(ExecutionTime(0)), false, true, Panic("Compile_Error.Error", List(c75803f2-3fb3-426f-bb8a-c7bbec6cae3a)))))), Response(None, ExecutionFailed(55b911ed-f384-460a-9410-da16d121085b, Diagnostic(Error, Some("Compile_Error.Error"), Some(/tmp/enso-test-packages2956044925097422099/src/Main.enso), Some(Range(Position(2, 8), Position(2, 17))), Some(c75803f2-3fb3-426f-bb8a-c7bbec6cae3a), Vector(StackTraceElement("Main.main", Some(/tmp/enso-test-packages2956044925097422099/src/Main.enso), Some(Range(Position(2, 8), Position(2, 17))), Some(c75803f2-3fb3-426f-bb8a-c7bbec6cae3a)))))), Response(None, BackgroundJobsStartedNotification()), Response(None, BackgroundJobsStartedNotification())) 



did not contain the same elements as 


List(Response(None, BackgroundJobsStartedNotification()), Response(Some(0823c808-30ab-44bd-9e80-3c0cf7f32166), PushContextResponse(55b911ed-f384-460a-9410-da16d121085b)), Response(None, ExecutionUpdate(55b911ed-f384-460a-9410-da16d121085b, List(Diagnostic(Error, Some("The name `undefined` could not be found."), Some(/tmp/enso-test-packages2956044925097422099/src/Main.enso), Some(Range(Position(2, 8), Position(2, 17))), Some(c75803f2-3fb3-426f-bb8a-c7bbec6cae3a), Vector())))), Response(None, ExpressionUpdates(55b911ed-f384-460a-9410-da16d121085b, Set(ExpressionUpdate(c75803f2-3fb3-426f-bb8a-c7bbec6cae3a, Some("Standard.Builtins.Main.Panic"), None, Vector(ExecutionTime(0)), false, true, Panic("Compile_Error.Error", List(c75803f2-3fb3-426f-bb8a-c7bbec6cae3a)))))), Response(None, ExpressionUpdates(55b911ed-f384-460a-9410-da16d121085b, Set(ExpressionUpdate(11ba8aab-a7fd-4160-bf93-35c836273df9, Some("Standard.Builtins.Main.Panic"), None, Vector(ExecutionTime(0)), false, true, Panic("Compile_Error.Error", List(c75803f2-3fb3-426f-bb8a-c7bbec6cae3a)))))), Response(None, ExpressionUpdates(55b911ed-f384-460a-9410-da16d121085b, Set(ExpressionUpdate(115feac2-51fc-4191-8393-ea75a0f5e80b, Some("Standard.Builtins.Main.Panic"), None, Vector(ExecutionTime(0)), false, true, Panic("Compile_Error.Error", List(c75803f2-3fb3-426f-bb8a-c7bbec6cae3a)))))), Response(None, ExecutionComplete(55b911ed-f384-460a-9410-da16d121085b))) (RuntimeErrorsTest.scala:161)

e.g. we are not getting ExecutionFailed, but rather ExpressionUpdates because the commit removes many places where PanicSentinel gets thrown during a method invocation.

@enso-bot
Copy link

enso-bot bot commented Jul 26, 2023

Jaroslav Tulach reports a new STANDUP for yesterday (2023-07-25):

Progress: Jul 25 - 9 h

Next Day: Bugfixes & cleanup

Discord
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
Discord
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.

@enso-bot
Copy link

enso-bot bot commented Jul 28, 2023

Jaroslav Tulach reports a new STANDUP for yesterday (2023-07-27):

Progress: - SequenceLiteralNode is green: #7385

Next Day: Interop with Python

@mergify mergify bot closed this as completed in #7385 Jul 28, 2023
mergify bot pushed a commit that referenced this issue Jul 28, 2023
Fixes #7245.

![Vector with a panic](https://github.com/enso-org/enso/assets/26887752/eed01c6c-5492-4cc6-bd4f-63ba761db010)

The above picture shows that the _vector problem_ reported by #7245 is fixed.

# Important Notes
The fix modifies `SequenceLiteralNode` to recognize `PanicSentinel` and `throw` it as common in other places (like invoke function node, etc.).
@github-project-automation github-project-automation bot moved this from 👁️ Code review to 🟢 Accepted in Issues Board Jul 28, 2023
@enso-bot
Copy link

enso-bot bot commented Jul 29, 2023

Jaroslav Tulach reports a new STANDUP for yesterday (2023-07-28):

Progress: - merged Python interop, phase I: #7396

Next Day: BigInteger & Interop with Python

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants