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

Compiler Internal Error: Impossible here, static method get should be caught when translating application #10473

Open
jdunkerley opened this issue Jul 8, 2024 · 4 comments

Comments

@jdunkerley
Copy link
Member

Image

Add a unconnected component

node3 = get 1

And you get the above internal error and things don't work right

@jdunkerley jdunkerley added this to the 2024-08 Release milestone Jul 8, 2024
@JaroslavTulach JaroslavTulach self-assigned this Jul 9, 2024
@JaroslavTulach JaroslavTulach changed the title Bug: Internal Error Jul 9, 2024
@JaroslavTulach
Copy link
Member

It would be interesting to know the whole source code. Without the source code, I can only guess what could be the problem. Trying to parse:

node3 = get 1

yields:

e.enso:1:9: error: The name `get` could not be found.
    1 | node3 = get 1
      |         ^~~

that's correct.

@JaroslavTulach
Copy link
Member

JaroslavTulach commented Jul 11, 2024

This is the failing test:

diff --git engine/runtime-integration-tests/src/test/java/org/enso/compiler/ExecCompilerTest.java engine/runtime-integration-tests/src/test/java/org/enso/compiler/ExecCompilerTest.java
index d83891b7b5..b2ebe5bc4f 100644
--- engine/runtime-integration-tests/src/test/java/org/enso/compiler/ExecCompilerTest.java
+++ engine/runtime-integration-tests/src/test/java/org/enso/compiler/ExecCompilerTest.java
@@ -90,6 +90,25 @@ public class ExecCompilerTest {
     }
   }
 
+  @Test
+  public void testDoubleAssignmentError() throws Exception {
+    var module =
+        ctx.eval(
+            LanguageInfo.ID,
+            """
+    from Standard.Base import all
+
+    main =
+        node1 = node3 = get 3
+    """);
+    try {
+      var run = module.invokeMember("eval_expression", "main");
+      fail("Unexpected result: " + run);
+    } catch (PolyglotException ex) {
+      assertEquals("", ex.getMessage());
+    }
+  }
+
   @Test
   public void testDesugarOperatorsLeftRight() throws Exception {
     var module = ctx.eval(LanguageInfo.ID, """

it was actually pretty tricky to find the test case, as the same program yields normal compilation errors when executed from CLI. One really has to run in IDE's "non-strict errors" mode.

@JaroslavTulach
Copy link
Member

JaroslavTulach commented Jul 11, 2024

@kaz, the node3 = get 3 in node1 = node3 = get 3 is represented as application of function/operator named =. Is that desirable? Shouldn't = be a reserved keyword and not an operator?

The question is who should reject that syntax? parser? TreeToIr? Or some later phase in the compiler?

The error is yielded from here and I can generate better syntax error, but possibly we should not even get to this place.

@kazcw
Copy link
Contributor

kazcw commented Jul 11, 2024

That would be a syntax error. Only the parser should create syntax errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants