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 crash when ambiguous from conversions are encountered #7853

Closed
radeusgd opened this issue Sep 20, 2023 · 2 comments · Fixed by #8245
Closed

Compiler crash when ambiguous from conversions are encountered #7853

radeusgd opened this issue Sep 20, 2023 · 2 comments · Fixed by #8245
Assignees
Labels
--bug Type: bug -compiler p-low Low priority

Comments

@radeusgd
Copy link
Member

I wanted to see what currently happens when the user defines 'colliding' from converions (i.e. conversions for the same type from the same type).

from Standard.Base import all

type My_A
    Inner x
	Outer x

My_A.from (that:Text) = My_A.Inner that

My_A.from (that:Text) = My_A.Outer that

foo (m:My_A) = m.to_text

main =
    IO.println (foo "TEST")

Currently, this code crashes the compiler with the following stack trace:

Execution finished with an error: java.lang.IllegalArgumentException: requirement failed: end:40 must be less than or equal to length:39
        at <java> scala.Predef$.require(Predef.scala:337)
        at <java> fansi.Str.$anonfun$overlayAll$2(Fansi.scala:187)
        at <java> fansi.Str.$anonfun$overlayAll$2$adapted(Fansi.scala:179)
        at <java> scala.collection.IterableOnceOps.foreach(IterableOnce.scala:576)
        at <java> scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:574)
        at <java> scala.collection.AbstractIterable.foreach(Iterable.scala:933)
        at <java> scala.collection.IterableOps$WithFilter.foreach(Iterable.scala:903)
        at <java> fansi.Str.overlayAll(Fansi.scala:179)
        at <java> fansi.Str.overlay(Fansi.scala:167)
        at <java> org.enso.compiler.Compiler$DiagnosticFormatter.oneLineFromSourceColored(Compiler.scala:1190)
        at <java> org.enso.compiler.Compiler$DiagnosticFormatter.format(Compiler.scala:1090)
        at <java> org.enso.compiler.Compiler.$anonfun$reportDiagnostics$2(Compiler.scala:1029)
        at <java> org.enso.compiler.Compiler.$anonfun$reportDiagnostics$2$adapted(Compiler.scala:1028)
        at <java> scala.collection.immutable.List.foreach(List.scala:333)
        at <java> org.enso.compiler.Compiler.reportDiagnostics(Compiler.scala:1028)
        at <java> org.enso.compiler.Compiler.$anonfun$reportDiagnostics$1(Compiler.scala:1010)
        at <java> org.enso.compiler.Compiler.$anonfun$reportDiagnostics$1$adapted(Compiler.scala:1008)
        at <java> scala.collection.LinearSeqOps.foldLeft(LinearSeq.scala:183)
        at <java> scala.collection.LinearSeqOps.foldLeft$(LinearSeq.scala:179)
        at <java> scala.collection.immutable.List.foldLeft(List.scala:79)
        at <java> org.enso.compiler.Compiler.reportDiagnostics(Compiler.scala:1008)
        at <java> org.enso.compiler.Compiler.runErrorHandling(Compiler.scala:912)
        at <java> org.enso.compiler.Compiler.runCompilerPipeline(Compiler.scala:388)
        at <java> org.enso.compiler.Compiler.go$1(Compiler.scala:232)
        at <java> org.enso.compiler.Compiler.runInternal(Compiler.scala:238)
        at <java> org.enso.compiler.Compiler.run(Compiler.scala:135)
        at <java> org.enso.interpreter.runtime.Module.compile(Module.java:372)
        at <java> org.enso.interpreter.runtime.Module.compileScope(Module.java:299)
        at <java> org.enso.interpreter.runtime.Module$InvokeMember.doInvoke(Module.java:644)
        at <java> org.enso.interpreter.runtime.ModuleGen$InteropLibraryExports$Cached.executeAndSpecialize(ModuleGen.java:115)
        at <java> org.enso.interpreter.runtime.ModuleGen$InteropLibraryExports$Cached.invokeMember(ModuleGen.java:104)
        at <java> org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue$SharedInvokeNode.doDefault(PolyglotValueDispatch.java:4553)
        at <java> org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatchFactory$InteropValueFactory$SharedInvokeNodeGen$Inlined.executeAndSpecialize(PolyglotValueDispatchFactory.java:10292)
        at <java> org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatchFactory$InteropValueFactory$SharedInvokeNodeGen$Inlined.executeShared(PolyglotValueDispatchFactory.java:10244)
        at <java> org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue$InvokeNoArgsNode.doDefault(PolyglotValueDispatch.java:4618)
        at <java> org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatchFactory$InteropValueFactory$InvokeNoArgsNodeGen.executeImpl(PolyglotValueDispatchFactory.java:10528)
        at <java> org.graalvm.truffle/com.oracle.truffle.polyglot.HostToGuestRootNode.execute(HostToGuestRootNode.java:124)
        at <java> org.graalvm.sdk/org.graalvm.polyglot.Value.invokeMember(Value.java:972)
        at <java> org.enso.polyglot.Module.getAssociatedType(Module.scala:19)
        at <java> org.enso.runner.Main$.runMain(Main.scala:834)
        at <java> org.enso.runner.Main$.runSingleFile(Main.scala:764)
        at <java> org.enso.runner.Main$.run(Main.scala:646)
        at <java> org.enso.runner.Main$.main(Main.scala:1149)
        at <java> org.enso.runner.Main.main(Main.scala)

If I comment out any of the two conversions, it works fine, e.g.:

(Outer 'TEST')

So it seems that the compiler cannot handle seeing two colliding conversions next to each other.

@Akirathan Akirathan self-assigned this Sep 22, 2023
@jdunkerley jdunkerley added the p-low Low priority label Sep 26, 2023
@jdunkerley jdunkerley moved this from ❓New to 📤 Backlog in Issues Board Sep 26, 2023
@jdunkerley jdunkerley assigned radeusgd and unassigned Akirathan Oct 31, 2023
@jdunkerley jdunkerley moved this from 📤 Backlog to ❓New in Issues Board Oct 31, 2023
@jdunkerley jdunkerley moved this from ❓New to 📤 Backlog in Issues Board Oct 31, 2023
@radeusgd radeusgd moved this from 📤 Backlog to 🔧 Implementation in Issues Board Nov 6, 2023
@enso-bot
Copy link

enso-bot bot commented Nov 8, 2023

Radosław Waśko reports a new STANDUP for yesterday (2023-11-07):

Progress: Added tests. Implemented a workaround that fixes the symptoms - but not the root cause yet. Searching for the root cause. It should be finished by 2023-11-10.

Next Day: Next day I will be working on the same task. Dig to look for the root cause and try to fix that instead of a workaround.

@radeusgd radeusgd moved this from 🔧 Implementation to 👁️ Code review in Issues Board Nov 8, 2023
@enso-bot
Copy link

enso-bot bot commented Nov 9, 2023

Radosław Waśko reports a new STANDUP for yesterday (2023-11-08):

Progress: Found the cause in TreeToIR and created a proper fix. Added some more test cases. Removed workaround. Prepared the PR. Testing Pavel's Graal 21 migration on Windows. It should be finished by 2023-11-10.

Next Day: Next day I will be working on the same task. Get the PR merged, start work on anti-join.

@mergify mergify bot closed this as completed in #8245 Nov 11, 2023
@github-project-automation github-project-automation bot moved this from 👁️ Code review to 🟢 Accepted in Issues Board Nov 11, 2023
mergify bot pushed a commit that referenced this issue Nov 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
--bug Type: bug -compiler p-low Low priority
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants