ceylon
ceylon copied to clipboard
Strange backend error with Sparkjava framework.
I couldn't recreate this error without using Spark.
import spark { Spark { ... }, ... }
Object(Request, Response) index = (req, res) => "Hello";
shared void run() {
get("/", index);
}
source/func/run.ceylon:7: error: Ceylon backend error: cannot find symbol
get("/", index);
^
symbol: variable get_
location: class index_
error: Ceylon backend error: method invoked with incorrect number of arguments; expected 2, found 0
Note: Created module func/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 below
* a description of what you were trying to compile.
Thank you!
org.eclipse.ceylon.compiler.CompilerBugException: Bug
at org.eclipse.ceylon.compiler.CeylonCompileTool.handleExitCode(CeylonCompileTool.java:933)
at org.eclipse.ceylon.compiler.CeylonCompileTool.run(CeylonCompileTool.java:915)
at org.eclipse.ceylon.common.tools.CeylonTool.run(CeylonTool.java:537)
at org.eclipse.ceylon.common.tools.CeylonTool.execute(CeylonTool.java:413)
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 org.eclipse.ceylon.launcher.Launcher.runInJava7Checked(Launcher.java:117)
at org.eclipse.ceylon.launcher.Launcher.run(Launcher.java:47)
at org.eclipse.ceylon.launcher.Launcher.run(Launcher.java:40)
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 org.eclipse.ceylon.launcher.Bootstrap.runVersion(Bootstrap.java:171)
at org.eclipse.ceylon.launcher.Bootstrap.runInternal(Bootstrap.java:126)
at org.eclipse.ceylon.launcher.Bootstrap.run(Bootstrap.java:102)
at org.eclipse.ceylon.launcher.Bootstrap.main(Bootstrap.java:94)
Caused by: java.lang.RuntimeException: Error generating bytecode for source/func/run.ceylon
at org.eclipse.ceylon.compiler.java.tools.LanguageCompiler.genCodeUnlessError(LanguageCompiler.java:839)
at org.eclipse.ceylon.compiler.java.tools.LanguageCompiler.genCode(LanguageCompiler.java:776)
at org.eclipse.ceylon.langtools.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1573)
at org.eclipse.ceylon.compiler.java.tools.LanguageCompiler.generate(LanguageCompiler.java:953)
at org.eclipse.ceylon.langtools.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1537)
at org.eclipse.ceylon.langtools.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:902)
at org.eclipse.ceylon.langtools.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:860)
at org.eclipse.ceylon.compiler.java.tools.LanguageCompiler.compile(LanguageCompiler.java:270)
at org.eclipse.ceylon.compiler.java.launcher.Main.compile(Main.java:660)
at org.eclipse.ceylon.compiler.java.launcher.Main.compile(Main.java:563)
at org.eclipse.ceylon.compiler.java.launcher.Main.compile(Main.java:555)
at org.eclipse.ceylon.compiler.java.launcher.Main.compile(Main.java:544)
at org.eclipse.ceylon.compiler.CeylonCompileTool.run(CeylonCompileTool.java:914)
... 17 more
Caused by: java.lang.AssertionError: typecode ERROR
at org.eclipse.ceylon.langtools.tools.javac.jvm.Code.typecode(Code.java:248)
at org.eclipse.ceylon.langtools.tools.javac.jvm.Items$Item.coerce(Items.java:269)
at org.eclipse.ceylon.langtools.tools.javac.jvm.Gen.genExpr(Gen.java:948)
at org.eclipse.ceylon.langtools.tools.javac.jvm.Gen.visitSelect(Gen.java:2344)
at org.eclipse.ceylon.langtools.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1896)
at org.eclipse.ceylon.langtools.tools.javac.jvm.Gen.genExpr(Gen.java:946)
at org.eclipse.ceylon.langtools.tools.javac.jvm.Gen.visitApply(Gen.java:1840)
at org.eclipse.ceylon.langtools.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1464)
at org.eclipse.ceylon.langtools.tools.javac.jvm.Gen.genExpr(Gen.java:946)
at org.eclipse.ceylon.langtools.tools.javac.jvm.Gen.visitReturn(Gen.java:1806)
at org.eclipse.ceylon.langtools.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1383)
at org.eclipse.ceylon.langtools.tools.javac.jvm.Gen.genDef(Gen.java:736)
at org.eclipse.ceylon.langtools.tools.javac.jvm.Gen.genStat(Gen.java:771)
at org.eclipse.ceylon.langtools.tools.javac.jvm.Gen.genStat(Gen.java:757)
at org.eclipse.ceylon.langtools.tools.javac.jvm.Gen.genStats(Gen.java:808)
at org.eclipse.ceylon.langtools.tools.javac.jvm.Gen.visitBlock(Gen.java:1156)
at org.eclipse.ceylon.langtools.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:908)
at org.eclipse.ceylon.langtools.tools.javac.jvm.Gen.genDef(Gen.java:736)
at org.eclipse.ceylon.langtools.tools.javac.jvm.Gen.genStat(Gen.java:771)
at org.eclipse.ceylon.langtools.tools.javac.jvm.Gen.genMethod(Gen.java:1030)
at org.eclipse.ceylon.langtools.tools.javac.jvm.Gen.visitMethodDef(Gen.java:993)
at org.eclipse.ceylon.langtools.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:777)
at org.eclipse.ceylon.langtools.tools.javac.jvm.Gen.genDef(Gen.java:736)
at org.eclipse.ceylon.langtools.tools.javac.jvm.Gen.genClass(Gen.java:2458)
at org.eclipse.ceylon.compiler.java.tools.LanguageCompiler.genCodeUnlessError(LanguageCompiler.java:810)
... 29 more
This compiles!
import spark { Spark { ... }, ... }
shared void run() {
Object(Request, Response) index = (req, res) => "Hello";
get("/", index);
}
@fwgreen what does the generated Java code look like (--verbose=code)?
package func;
@.org.eclipse.ceylon.compiler.java.metadata.Ceylon(
major = 8,
minor = 1)
@.org.eclipse.ceylon.compiler.java.metadata.Method
public final class run_ {
private run_() {
}
@.ceylon.language.SharedAnnotation$annotation$
public static void run() {
.spark.Spark.get("/", new .spark.Route(){
@.org.eclipse.ceylon.compiler.java.metadata.Ignore
public .java.lang.Object $call$(final .java.lang.Object $param$0, final .java.lang.Object $param$1) {
final .spark.Request $ceylontmp$arg0 = (.spark.Request)$param$0;
final .spark.Response $ceylontmp$arg1 = (.spark.Response)$param$1;
return .func.index_.get_.$call$($ceylontmp$arg0, $ceylontmp$arg1);
}
@.java.lang.Override
public .java.lang.Object handle(@.org.eclipse.ceylon.compiler.java.metadata.Name("arg0")
final .spark.Request arg0, @.org.eclipse.ceylon.compiler.java.metadata.Name("arg1")
final .spark.Response arg1) {
return $call$(.org.eclipse.ceylon.compiler.java.Util.checkNull(arg0), .org.eclipse.ceylon.compiler.java.Util.checkNull(arg1));
}
});
}
@.org.eclipse.ceylon.compiler.java.metadata.Ignore
public static void main(.java.lang.String[] args) {
.org.eclipse.ceylon.compiler.java.Util.storeArgs(args);
.func.run_.run();
}
}
@.org.eclipse.ceylon.compiler.java.metadata.Ceylon(
major = 8,
minor = 1)
@.org.eclipse.ceylon.compiler.java.metadata.Attribute
@.org.eclipse.ceylon.compiler.java.metadata.Name("index")
final class index_ {
private index_() {
}
private static final .ceylon.language.Callable<? extends .java.lang.Object> $object$;
@.org.eclipse.ceylon.compiler.java.metadata.Ignore
private static volatile boolean $init$$object$ = false;
private static final .java.lang.Throwable $initException$;
static {
try {
$object$ = new @.org.eclipse.ceylon.compiler.java.metadata.LocalDeclaration @.org.eclipse.ceylon.compiler.java.metadata.Name("anonymous#0") @.org.eclipse.ceylon.compiler.java.metadata.Method .org.eclipse.ceylon.compiler.java.language.AbstractCallable<.ceylon.language.String>(.ceylon.language.String.$TypeDescriptor$, .org.eclipse.ceylon.compiler.java.runtime.model.TypeDescriptor.tuple(false, false, -1, .org.eclipse.ceylon.compiler.java.runtime.model.TypeDescriptor.klass(.spark.Request.class), .org.eclipse.ceylon.compiler.java.runtime.model.TypeDescriptor.klass(.spark.Response.class)), "String(Request, Response)", (short)-1)
@.org.eclipse.ceylon.compiler.java.metadata.LocalDeclaration
@.org.eclipse.ceylon.compiler.java.metadata.Name("anonymous#0")
@.org.eclipse.ceylon.compiler.java.metadata.Method
{
@.java.lang.Override
@.org.eclipse.ceylon.compiler.java.metadata.Ignore
public .ceylon.language.String $call$(final .java.lang.Object $param$0, final .java.lang.Object $param$1) {
final .spark.Request req = (.spark.Request)$param$0;
final .spark.Response res = (.spark.Response)$param$1;
return .ceylon.language.String.instance("Hello");
}
};
.func.index_.$init$$object$ = true;
$initException$ = null;
} catch (.java.lang.Throwable x) {
$initException$ = x;
$object$ = null;
.func.index_.$init$$object$ = false;
}
}
@.org.eclipse.ceylon.common.NonNull
@.org.eclipse.ceylon.compiler.java.metadata.TypeInfo("ceylon.language::Object(spark::Request, spark::Response)")
public static .ceylon.language.Callable<? extends .java.lang.Object> get_() {
if (.func.index_.$init$$object$) {
return .func.index_.$object$;
} else {
if ($initException$ != null) .org.eclipse.ceylon.compiler.java.Util.rethrow($initException$);
throw new .ceylon.language.InitializationError("Cyclic initialization trying to read the value of \'index\' before it was set");
}
}
}
Java code generated for RegularFileObject[source/func/module.ceylon]
package func;
@.org.eclipse.ceylon.compiler.java.metadata.Ceylon(
major = 8,
minor = 1)
@.org.eclipse.ceylon.compiler.java.metadata.Module(
name = "func",
version = "0.0.1",
dependencies = {
@.org.eclipse.ceylon.compiler.java.metadata.Import(
name = "com.sparkjava:spark-core",
version = "2.7.2",
namespace = "maven"),
@.org.eclipse.ceylon.compiler.java.metadata.Import(
name = "ceylon.language",
version = "1.3.4-SNAPSHOT")},
nativeBackends = {"jvm"})
@.ceylon.language.NativeAnnotation$annotation$(backends = "jvm")
final class $module_ {
private $module_() {
}
public static final .java.lang.String com$sparkjava:spark-core = null;
}
Java code generated for RegularFileObject[source/func/package.ceylon]
package func;
@.org.eclipse.ceylon.compiler.java.metadata.Ceylon(
major = 8,
minor = 1)
@.org.eclipse.ceylon.compiler.java.metadata.Package(
name = "func",
shared = true)
@.ceylon.language.SharedAnnotation$annotation$
final class $package_ {
private $package_() {
}
}
In this line:
.func.index_.get_.$call$($ceylontmp$arg0, $ceylontmp$arg1)
We appear to be missing the argument list () of get_().