ceylon / ceylon-js

DEPRECATED
Apache License 2.0
54 stars 9 forks source link

TypeError with method call involving spread operator #508

Closed jvasileff closed 9 years ago

jvasileff commented 9 years ago

@chochos the recent fixes look good, but I'm still having trouble with my original use case. Hopefully this is a better approximation:

shared void runTests() {
    value args = ["Cey", "lon"];
    exec2((String x, String y) => x.plus(y), identity<[String, String]>, args);
    // TypeError: Object [object Object] has no method 'plus'

    exec2(uncurry(String.plus), identity<[String, String]>, args);
    // TypeError: Cannot read property 'jsc$' of undefined 
}

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

I wasn't able to further isolate the issue. The error does not occur if exec2 is removed, with its operations performed directly by runTests. It also works without destructuring:

    value xs = transform(args);
    print(op(*xs));

or by using unflatten as a workaround:

    value [*xs] = transform(args);
    print(unflatten(op)(xs));
chochos commented 9 years ago

Weird, I tested on your original use cases and they all passed.

chochos commented 9 years ago

Mmmm so maybe the problem is in destructuring the args value [*xs] = transform(args)...

chochos commented 9 years ago

ah no, it's something else. Anyway, fix coming right up...

jvasileff commented 9 years ago

Great, thanks! Everything works now.