diff --git a/engine/runtime-parser/src/main/java/org/enso/compiler/core/TreeToIr.java b/engine/runtime-parser/src/main/java/org/enso/compiler/core/TreeToIr.java index f2d4f40b45ac..74eb9f34bc8c 100644 --- a/engine/runtime-parser/src/main/java/org/enso/compiler/core/TreeToIr.java +++ b/engine/runtime-parser/src/main/java/org/enso/compiler/core/TreeToIr.java @@ -605,11 +605,16 @@ private Expression translateCall(Tree ast, boolean isMethod) { if (self == null || !invoke) { return null; } - var expr = translateExpression(l.getExpression().getExpression(), true); - if (expr instanceof Application.Prefix pref) { - var arg = new CallArgument.Specified(Option.empty(), self, self.location(), meta(), diag()); - expr = new Application.Prefix(pref.function(), join(arg, pref.arguments()), false, expr.location(), meta(), diag()); - } + var expr = switch (translateExpression(l.getExpression().getExpression(), true)) { + case Application.Prefix pref -> { + var arg = new CallArgument.Specified(Option.empty(), self, self.location(), meta(), diag()); + yield new Application.Prefix(pref.function(), join(arg, pref.arguments()), false, pref.location(), meta(), diag()); + } + case Expression any -> { + var arg = new CallArgument.Specified(Option.empty(), self, self.location(), meta(), diag()); + yield new Application.Prefix(any, join(arg, nil()), false, any.location(), meta(), diag()); + } + }; var loc = getIdentifiedLocation(l.getExpression().getExpression()); args.add(at, new CallArgument.Specified(Option.empty(), expr, loc, meta(), diag())); self = expr; diff --git a/engine/runtime-parser/src/test/java/org/enso/compiler/core/EnsoParserTest.java b/engine/runtime-parser/src/test/java/org/enso/compiler/core/EnsoParserTest.java index e90ea7cb46cb..254577a45410 100644 --- a/engine/runtime-parser/src/test/java/org/enso/compiler/core/EnsoParserTest.java +++ b/engine/runtime-parser/src/test/java/org/enso/compiler/core/EnsoParserTest.java @@ -1,18 +1,17 @@ package org.enso.compiler.core; -import com.oracle.truffle.api.source.Source; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.StandardOpenOption; import java.util.List; import java.util.function.Function; + import org.enso.compiler.core.ir.Module; import org.junit.AfterClass; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; - import org.junit.BeforeClass; import org.junit.Test; @@ -1280,6 +1279,28 @@ public void testBlockSyntaxOperators2() throws Exception { """); } + @Test + public void testBlockSyntaxOperators3() throws Exception { + equivalenceTest(""" + v = (rect1 . width) . center + """, """ + v = rect1 + . width + . center + """); + } + + @Test + public void testBlockSyntaxOperators4() throws Exception { + equivalenceTest(""" + v = (rect1 . width 4) . center 3 2 + """, """ + v = rect1 + . width 4 + . center 3 2 + """); + } + @Test public void testPrivateModules() throws Exception { List moduleCodes = List.of( @@ -1338,8 +1359,7 @@ private static Module compile(String code) { } public static Module compile(EnsoParser c, String code) { - var src = Source.newBuilder("enso", code, "test-" + Integer.toHexString(code.hashCode()) + ".enso").build(); - var ir = c.compile(src.getCharacters()); + var ir = c.compile(code); assertNotNull("IR was generated", ir); return ir; }