ceylon / ceylon-js

DEPRECATED
Apache License 2.0
54 stars 9 forks source link

Error calling uncurried function received as an argument to a generic method #486

Closed jvasileff closed 9 years ago

jvasileff commented 9 years ago

The code below produces an error in the last three cases:

shared void uncurryJS() {
    value args = ["Cey", "lon"];
    exec2((String x, String y) => x.plus(y), args); // ok
    exec2(plus<String>, args); // ok
    exec1(uncurry(String.plus), args); // ok
    exec2(uncurry(String.plus), args); // error
    exec3(uncurry(String.plus), args); // error
    exec4(uncurry(String.plus), args); // error
}

void exec1(String(String, String) op, [String, String] args) {
    print(op(*args));
}

void exec2<Args>(String(*Args) op, Args args)
        given Args satisfies Anything[] {
    print(op(*args));
}

void exec3<Args>(String(*Args) op, Args args)
        given Args satisfies [Anything, Anything] {
    print(op(*args));
}

void exec4<Args>(String(*Args) op, Args args)
        given Args satisfies [String, String] {
    print(op(*args));
}

The error:

/Users/jvasileff/Applications/eclipse-4.4.1-ceylon/plugins/com.redhat.ceylon.dist.repo_1.1.1.v20150115-0214/repo/ceylon/language/1.1.1/ceylon.language-1.1.1.js:2611
var size = this.codePoints + other.codePoints;
                                  ^
TypeError: Cannot read property 'codePoints' of undefined
    at String.$init$$_String.string$.plus (/Users/jvasileff/Applications/eclipse-4.4.1-ceylon/plugins/com.redhat.ceylon.dist.repo_1.1.1.v20150115-0214/repo/ceylon/language/1.1.1/ceylon.language-1.1.1.js:2611:35)
    at JsCallable.f2 (/Users/jvasileff/Applications/eclipse-4.4.1-ceylon/plugins/com.redhat.ceylon.dist.repo_1.1.1.v20150115-0214/repo/ceylon/language/1.1.1/ceylon.language-1.1.1.js:617:10)
    at ru (/Users/jvasileff/Applications/eclipse-4.4.1-ceylon/plugins/com.redhat.ceylon.dist.repo_1.1.1.v20150115-0214/repo/ceylon/language/1.1.1/ceylon.language-1.1.1.js:3266:49)
    at $JsCallable.nm (/Users/jvasileff/Applications/eclipse-4.4.1-ceylon/plugins/com.redhat.ceylon.dist.repo_1.1.1.v20150115-0214/repo/ceylon/language/1.1.1/ceylon.language-1.1.1.js:3126:208)
    at rf (/Users/jvasileff/Applications/eclipse-4.4.1-ceylon/plugins/com.redhat.ceylon.dist.repo_1.1.1.v20150115-0214/repo/ceylon/language/1.1.1/ceylon.language-1.1.1.js:3245:8)
    at exec2 (/Users/jvasileff/Dropbox/Repos/jv/sandbox-ceylon-snapjs/modules/sandbox/ceylon/snapjs/base/0.0.1/sandbox.ceylon.snapjs.base-0.0.1.js:129:17)
    at uncurryJS (/Users/jvasileff/Dropbox/Repos/jv/sandbox-ceylon-snapjs/modules/sandbox/ceylon/snapjs/base/0.0.1/sandbox.ceylon.snapjs.base-0.0.1.js:115:5)
    at [eval]:1:354
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:456:26)