Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type constructors with type constructors in the return break at runtime #607

Open
jvasileff opened this issue Jul 26, 2015 · 1 comment
Open
Milestone

Comments

@jvasileff
Copy link
Member

Including something like:

alias AdditionLikeOperation
    =>  <Number> given Number satisfies Summable<Number>
        =>  Number(Number,Number);

or

alias Wrapper<Box> given Box<E>
    =>  <Element>
        =>  Box<Element>(Element);

in a module causes a runtime error like:

function Wrapper(){var $2=$3();$2.$crtmm$=function(){return{mod:$CCMM$,tp:{Box
                          ^
ReferenceError: $3 is not defined
    at Wrapper (/Users/jvasileff/Transient/simpleT/modules/simple/1.0.0/simple-1.0.0.js:20:27)

and including something like:

alias ReturnsSetCtor => <<T> given T satisfies Object => Set<T>({T*})>();

results in

Arguments$Callable:{t:m$1.Empty},Return$Callable:$3(),a:{T$Anonymous#0:{/*NO P
                                                                    ^
SyntaxError: Unexpected token ILLEGAL
    at Module._compile (module.js:439:25)
@jvasileff
Copy link
Member Author

In case it helps, here is a test that works today:

shared void run() {
    {Singleton<Integer>|Singleton<Float>*} nums;
    nums = wrapConcat1<Singleton, Integer, Float>(
                Singleton, {1,2,3}, {1.0,2.0,3.0});
    assert([[1],[2],[3],[1.0],[2.0],[3.0]] == nums.sequence());
}

{Box<A>|Box<B>*} wrapConcat1<Box, A, B>(
        Box<Element> wrap<Element>(Element e),
        {A*} as, {B*} bs)
        given Box<E>
    =>  as.map(wrap).chain(bs.map(wrap));

but the similar test below fails to run:

shared void run() {
    {Singleton<Integer>|Singleton<Float>*} nums;
    nums = wrapConcat2<Singleton, Integer, Float>(
                Singleton, {1,2,3}, {1.0,2.0,3.0});
    assert([[1],[2],[3],[1.0],[2.0],[3.0]] == nums.sequence());
}

alias Wrapper<Box> given Box<E>
    =>  <Element>
        =>  Box<Element>(Element);

{Box<A>|Box<B>*} wrapConcat2<Box, A, B>(
        Wrapper<Box> wrap,
        {A*} as, {B*} bs)
        given Box<E>
    =>  as.map(wrap).chain(bs.map(wrap));

with:

$ ceylon run-js --compile=force simple
Source found for module simple, compiling...
Note: Created module simple/1.0.0

/Users/jvasileff/Transient/simpleT/modules/simple/1.0.0/simple-1.0.0.js:23
function Wrapper(){var $4=$5();$4.$crtmm$=function(){return{mod:$CCMM$,tp:{Box
                          ^
ReferenceError: $5 is not defined
    at Wrapper (/Users/jvasileff/Transient/simpleT/modules/simple/1.0.0/simple-1.0.0.js:23:27)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants