eclipse-archived / ceylon

The Ceylon compiler, language module, and command line tools
http://ceylon-lang.org
Apache License 2.0
398 stars 62 forks source link

"Compiler bug" referencing static Callable field #7396

Open kingjon3377 opened 6 years ago

kingjon3377 commented 6 years ago

The following code fails to compile with several "compiler bug" errors:

class Referenced {
    static void defMethod() {}
    static variable Anything() mutableReference = defMethod;
    shared static Anything() sharedReference => mutableReference;
    shared new () {}
    shared void mutator() => mutableReference = noop;
}
shared void run() => Referenced.sharedReference();

Compiler output:

source/funcval/mwe.ceylon:8: error: compiler bug: com.redhat.ceylon.model.typechecker.model.Value cannot be cast to com.redhat.ceylon.model.typechecker.model.Functional at com.redhat.ceylon.compiler.java.codegen.ExpressionTransformer.transform(ExpressionTransformer.java:4706)
shared void run() => Referenced.sharedReference();
                     ^
source/funcval/mwe.ceylon:8: error: compiler bug: visitor didn't yield any result at com.redhat.ceylon.compiler.java.codegen.ExpressionTransformer.transformExpression(ExpressionTransformer.java:375)
shared void run() => Referenced.sharedReference();
                     ^
source/funcval/mwe.ceylon:8: error: compiler bug: visitor didn't yield any result at unknown
shared void run() => Referenced.sharedReference();
                     ^
Note: Created module funcval/0.0.1
ceylon compile: Fatal error: The compiler exited abnormally (4) due to a bug in the compiler.
Please report it:
 https://github.com/ceylon/ceylon/issues/new
Please include:

* the stacktrace printed above
* the stacktrace printed below
* a description of what you were trying to compile.

Thank you!
com.redhat.ceylon.compiler.CompilerBugException: Codegen Bug
    at com.redhat.ceylon.compiler.CeylonCompileTool.handleExitCode(CeylonCompileTool.java:933)
    at com.redhat.ceylon.compiler.CeylonCompileTool.run(CeylonCompileTool.java:915)
    at com.redhat.ceylon.common.tools.CeylonTool.run(CeylonTool.java:547)
    at com.redhat.ceylon.common.tools.CeylonTool.execute(CeylonTool.java:423)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.redhat.ceylon.launcher.Launcher.runInJava7Checked(Launcher.java:108)
    at com.redhat.ceylon.launcher.Launcher.run(Launcher.java:38)
    at com.redhat.ceylon.launcher.Launcher.run(Launcher.java:31)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.redhat.ceylon.launcher.Bootstrap.runVersion(Bootstrap.java:162)
    at com.redhat.ceylon.launcher.Bootstrap.runInternal(Bootstrap.java:117)
    at com.redhat.ceylon.launcher.Bootstrap.run(Bootstrap.java:93)
    at com.redhat.ceylon.launcher.Bootstrap.main(Bootstrap.java:85)
Caused by: java.lang.RuntimeException: Error generating bytecode for source/funcval/mwe.ceylon
    at com.redhat.ceylon.compiler.java.tools.LanguageCompiler.genCodeUnlessError(LanguageCompiler.java:839)
    at com.redhat.ceylon.compiler.java.tools.LanguageCompiler.genCode(LanguageCompiler.java:776)
    at com.redhat.ceylon.langtools.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1575)
    at com.redhat.ceylon.compiler.java.tools.LanguageCompiler.generate(LanguageCompiler.java:953)
    at com.redhat.ceylon.langtools.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1539)
    at com.redhat.ceylon.langtools.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:904)
    at com.redhat.ceylon.langtools.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:862)
    at com.redhat.ceylon.compiler.java.tools.LanguageCompiler.compile(LanguageCompiler.java:270)
    at com.redhat.ceylon.compiler.java.launcher.Main.compile(Main.java:660)
    at com.redhat.ceylon.compiler.java.launcher.Main.compile(Main.java:563)
    at com.redhat.ceylon.compiler.java.launcher.Main.compile(Main.java:555)
    at com.redhat.ceylon.compiler.java.launcher.Main.compile(Main.java:544)
    at com.redhat.ceylon.compiler.CeylonCompileTool.run(CeylonCompileTool.java:914)
    ... 17 more
Caused by: java.lang.AssertionError
    at com.redhat.ceylon.langtools.tools.javac.util.Assert.error(Assert.java:126)
    at com.redhat.ceylon.langtools.tools.javac.tree.JCTree$Visitor.visitTree(JCTree.java:2627)
    at com.redhat.ceylon.langtools.tools.javac.tree.JCTree$Visitor.visitErroneous(JCTree.java:2624)
    at com.redhat.ceylon.langtools.tools.javac.tree.JCTree$JCErroneous.accept(JCTree.java:2426)
    at com.redhat.ceylon.langtools.tools.javac.jvm.Gen.genExpr(Gen.java:949)
    at com.redhat.ceylon.langtools.tools.javac.jvm.Gen.visitExec(Gen.java:1779)
    at com.redhat.ceylon.langtools.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1295)
    at com.redhat.ceylon.langtools.tools.javac.jvm.Gen.genDef(Gen.java:739)
    at com.redhat.ceylon.langtools.tools.javac.jvm.Gen.genStat(Gen.java:774)
    at com.redhat.ceylon.langtools.tools.javac.jvm.Gen.genStat(Gen.java:760)
    at com.redhat.ceylon.langtools.tools.javac.jvm.Gen.genStats(Gen.java:811)
    at com.redhat.ceylon.langtools.tools.javac.jvm.Gen.visitBlock(Gen.java:1159)
    at com.redhat.ceylon.langtools.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:908)
    at com.redhat.ceylon.langtools.tools.javac.jvm.Gen.genDef(Gen.java:739)
    at com.redhat.ceylon.langtools.tools.javac.jvm.Gen.genStat(Gen.java:774)
    at com.redhat.ceylon.langtools.tools.javac.jvm.Gen.genMethod(Gen.java:1033)
    at com.redhat.ceylon.langtools.tools.javac.jvm.Gen.visitMethodDef(Gen.java:996)
    at com.redhat.ceylon.langtools.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:777)
    at com.redhat.ceylon.langtools.tools.javac.jvm.Gen.genDef(Gen.java:739)
    at com.redhat.ceylon.langtools.tools.javac.jvm.Gen.genClass(Gen.java:2461)
    at com.redhat.ceylon.compiler.java.tools.LanguageCompiler.genCodeUnlessError(LanguageCompiler.java:810)
    ... 29 more

ceylon --version reports ceylon version 1.3.3 0d594b3 (Contents May Differ); if it's relevant, this is on Mac OS X Sierra.

gavinking commented 6 years ago

Ouch!