-
Notifications
You must be signed in to change notification settings - Fork 324
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
Wrong error recovery: bind all things on the right side of unclosed (
#6741
Comments
Attaching logs from LS. I can see there is a message from the LS: {
"jsonrpc": "2.0",
"method": "executionContext/executionStatus",
"params": {
"contextId": "c3efe72c-adec-4d65-a814-8161b983f3f2",
"diagnostics": [
{
"kind": "Error",
"message": "Unexpected expression.",
"path": {
"rootId": "f80686e2-27f0-4417-8104-2c89df908fd6",
"segments": [
"src",
"Main.enso"
]
},
"location": {
"start": {
"line": 10,
"character": 29
},
"end": {
"line": 10,
"character": 30
}
},
"expressionId": "27cba2e4-3e06-4970-8cfa-d3155a037c4c",
"stack": []
}
]
}
} So LS sends correct diagnostics. I am not certain how this message is handled by the IDE? cc @farmaazon |
We don't read execution Status (yet). The error on nodes are taken from the (the first error in probably due to previewing the selected suggestion). |
Indeed, we receive it in the Payload. Moreover, I checked another cases. When I create a node with just a map constructor, I got the proper result: Connecting it to Only when I copied the expression, I got the error as @radeusgd did: Now, I have a good theory, and I'm almost sure I am right: In the expression
So, what we can do?
Whatever the answer is, GUI team cannot provide it. Putting back to triage. |
I think we should do this. It is better to assume the expression is incomplete than incorrect. |
(
We'd like following test: enso$ git diff engine/runtime/src/test/java/org/enso/compiler/ExecCompilerTest.java
diff --git engine/runtime/src/test/java/org/enso/compiler/ExecCompilerTest.java engine/runtime/src/test/java/org/enso/compiler/ExecCompilerTest.java
index 08f424e355..97711770eb 100644
--- engine/runtime/src/test/java/org/enso/compiler/ExecCompilerTest.java
+++ engine/runtime/src/test/java/org/enso/compiler/ExecCompilerTest.java
@@ -2,13 +2,16 @@ package org.enso.compiler;
import java.io.OutputStream;
import java.nio.file.Paths;
+
import org.enso.polyglot.RuntimeOptions;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.PolyglotException;
import org.junit.AfterClass;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
import org.junit.BeforeClass;
import org.junit.Test;
-import static org.junit.Assert.*;
public class ExecCompilerTest {
private static Context ctx;
@@ -82,4 +85,26 @@ public class ExecCompilerTest {
var err = run.execute(0);
assertEquals("Error: Module is not a part of a package.", err.asString());
}
+
+ @Test
+ public void testExecuteWithError() throws Exception {
+ var module =
+ ctx.eval(
+ "enso",
+ """
+ polyglot java import java.lang.System
+
+ rename_column ~x =
var err = run.execute(0);
assertEquals("Error: Module is not a part of a package.", err.asString());
}
+
+ @Test
+ public void testExecuteWithError() throws Exception {
+ var module =
+ ctx.eval(
+ "enso",
+ """
+ polyglot java import java.lang.System
+
+ rename_column ~x =
+ System.out.println "in rename_column"
+ x
+ from_vector ~v =
+ System.out.println "in from_vector"
+ v
+
+ a x y = rename_column (from_vector [[x, y]]
+ """);
+ var run = module.invokeMember("eval_expression", "a");
+ var err = run.execute("Hi", "There");
+ assertEquals("Got two values", 2, err.getArraySize());
+ }
} to print |
When I expand the enso$ git diff engine/runtime/src/test/java/org/enso/compiler/ErrorCompilerTest.java
diff --git engine/runtime/src/test/java/org/enso/compiler/ErrorCompilerTest.java engine/runtime/src/test/java/org/enso/compiler/ErrorCompilerTest.java
index d4c0fc2300..b98a49407a 100644
--- engine/runtime/src/test/java/org/enso/compiler/ErrorCompilerTest.java
+++ engine/runtime/src/test/java/org/enso/compiler/ErrorCompilerTest.java
@@ -358,6 +357,14 @@ public class ErrorCompilerTest extends CompilerTest {
assertSingleSyntaxError(ir, IR$Error$Syntax$UnexpectedExpression$.MODULE$, "Unexpected expression", 60, 62);
}
+ @Test
+ public void testUnclosedBracket() throws Exception {
+ var ir = parse("""
+ a x y = rename_column (from_vector [[x, y]]
+ """);
+ assertSingleSyntaxError(ir, IR$Error$Syntax$UnexpectedExpression$.MODULE$, "Unexpected expression", 60, 62);
+ }
+
@Test
public void testNPE183863754() throws Exception {
var ir = parse(""" I can see that I get following
I don't think |
Implements #5453. Syntax changes: - Eliminate old non-decimal number syntax. - Unspaced application like `f(x)` is now an error. - Applying `:` to a non-QN in statement context is allowed and produces a `TypeAnnotated` (fixes #6152). API changes: - All fixed-content tokens are now distinct types. Error improvements (fixes #5444), especially for: - Out-of-context expressions/statements - Statement syntaxes - Named-app syntax - Unspaced-application errors - Number syntax - Private annotations (fixes #10137) - Parens (fixes #6741) - Type defs (fixes #8633) - Fix some panics caused by invalid expressions, found by parsing non-Enso code. - Reject some operations in pattern context, e.g. `1 + 1 = 2`. - Eliminate `export` with `all` or `hiding` (#10258). Improve Rust parsing performance by 33%; now 20 MB/s on my bench machine: - Stream lexer to parser. - New, faster parser for type defs, statements, numbers. - More efficient tree layout (fixes #5452). Improve backend parsing performance additionally: - Backend now uses optimized parser build (in debug builds, debug-assertions are still enabled). Build improvements: - Fix some redundancy between `sbt` and build script: now only `sbt` compiles JNI and generates parser's Java bindings for backend use. Build script generates Java to a different directory when parser serialization self-test is requested. - Improve `sbt` detection of changed parser; this should reduce the need for clean builds in CI. Testing: - Add binary target for fuzzing with AFL.
TL;DR
In the expression
foo.rename column (Map.from_vector [["Value1", "Attack Damage"]]
therename_column
method gets actually two arguments:(Map.from_vector
[["Value1", "Attack Damage"]]
Usages of the first argument inside
rename_column
propagate the panic properly; but before it's returned, we try to callif_then_else
on the second (which isVector
, notBoolean
) what results in a newPanic
, overriding the old one.So, what we can do?
Map.from_vector [["Value1", "Attack Damage"]]
will be one argument, not two.Original Report
One example repro is to create a table by loading a CSV or
Table.new [["X", [1,2,3]]]
and then calling:(note the missing
)
here).What I get in the REPL is a slightly cryptic, but helpful syntax error:
But somehow, in the IDE I get results like:
in the preview:
or after submitting with Ctrl+Enter:
The text was updated successfully, but these errors were encountered: