ceylon / ceylon-js

DEPRECATED
Apache License 2.0
54 stars 9 forks source link

`undefined` error when using `completeCompilationUnit` value #574

Closed lucaswerkmeister closed 9 years ago

lucaswerkmeister commented 9 years ago
module tmp "1.0.0" {
    shared import ceylon.ast.samples "1.1.1";
}

import ceylon.ast.samples.completeCompilationUnit { completeCompilationUnit }
shared void run() {
    value v = completeCompilationUnit;
}

tmp-1.0.0.js:16

var $3=m$2.completeCompilationUnit$ceylon$ast$samples$completeCompilationUnit(
           ^

TypeError: undefined is not a function at run (…/tmp-1.0.0.js:16:12) at [eval]:1:273 at Object.exports.runInThisContext (vm.js:74:17) at Object. ([eval]-wrapper:6:22) at Module._compile (module.js:460:26) at evalScript (node.js:431:25) at startup (node.js:90:7) at node.js:814:3

generated code

lucaswerkmeister commented 9 years ago

I haven’t been able to reproduce this with values from other modules so far.

lucaswerkmeister commented 9 years ago

completeCompilationUnit is defined here and used here. The bug can also be reproduced by running ant test-js in ceylon.ast (though then the exception is wrapped in a NativeError).

lucaswerkmeister commented 9 years ago

ceylon.parse seems to have the same error: when running ceylon compile-js '*'; ceylon test-js test.ceylon.parse, two tests (broadGeneric, sequence) fail with “undefined is not a function”.

chochos commented 9 years ago

I can't compile ceylon.ast

lucaswerkmeister commented 9 years ago

Weird, ant clean test-js works here

chochos commented 9 years ago

I had to manually compile core and its tests but I managed to get the error now.

lucaswerkmeister commented 9 years ago

What error did you get?

chochos commented 9 years ago

It's a different one, the problem is it couldn't find the samples module (because I didn't compile it). But I get errors trying to compile that one as well as the redhat module, on CLI.

chochos commented 9 years ago

Ah, found it! The module ceylon.ast.samples has no root package, and that causes the wrong name to be generated. Just running some tests before I push the fix...

lucaswerkmeister commented 9 years ago

Thanks! I’m still getting an error, but now it seems to be a different one:

$ ceylon run-js --run=test.ceylon.ast.core::testEditor test.ceylon.ast.core
/home/lucas/git/ceylon/ceylon-dist/dist/repo/ceylon/language/1.1.1/ceylon.language-1.1.1.js:549
if (lt[i].t===iu) {
         ^
TypeError: Cannot read property 't' of undefined
    at flattentype$ (/home/lucas/git/ceylon/ceylon-dist/dist/repo/ceylon/language/1.1.1/ceylon.language-1.1.1.js:549:10)
    at mut$ (/home/lucas/git/ceylon/ceylon-dist/dist/repo/ceylon/language/1.1.1/ceylon.language-1.1.1.js:561:7)
    at ChainedIterator (/home/lucas/git/ceylon/ceylon-dist/dist/repo/ceylon/language/1.1.1/ceylon.language-1.1.1.js:3725:80)
    at that.iterator (/home/lucas/git/ceylon/ceylon-dist/dist/repo/ceylon/language/1.1.1/ceylon.language-1.1.1.js:1165:8)
    at m$1.tpl$.m$1.for$.Element$Iterable [as makeNextFunc] (/home/lucas/git/ceylon/ceylon.ast/modules/ceylon/ast/core/1.1.1/ceylon.ast.core-1.1.1.js:11472:25)
    at for$$proto.iterator (/home/lucas/git/ceylon/ceylon-dist/dist/repo/ceylon/language/1.1.1/ceylon.language-1.1.1.js:1018:22)
    at Object.tpl$ (/home/lucas/git/ceylon/ceylon-dist/dist/repo/ceylon/language/1.1.1/ceylon.language-1.1.1.js:1109:22)
    at node$.transformChildren (/home/lucas/git/ceylon/ceylon.ast/modules/ceylon/ast/core/1.1.1/ceylon.ast.core-1.1.1.js:11471:12)
    at node$.visitChildren (/home/lucas/git/ceylon/ceylon.ast/modules/ceylon/ast/core/1.1.1/ceylon.ast.core-1.1.1.js:11487:14)
    at visitor$.visitNode (/home/lucas/git/ceylon/ceylon.ast/modules/ceylon/ast/core/1.1.1/ceylon.ast.core-1.1.1.js:12679:13)

Should I report that as a separate bug?

chochos commented 9 years ago

I did see that one, but I think it may be due to the ast samples module not being complete – I just can't get it to compile for JS, and the tests use it but since it's incomplete, that may be the cause for the error...

lucaswerkmeister commented 9 years ago

Oh, now I get the error you’re mentioning as well – but only when running ceylon compile ceylon.ast.samples, not with ant clean compile-js. Very strange…

lucaswerkmeister commented 9 years ago

579, a model loader issue

lucaswerkmeister commented 9 years ago

Okay, #579 is fixed, and I’m still getting that other undefined error. No compiler errors in ant clean test-js.

chochos commented 9 years ago

no, this is a bug in native code.