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

Anonymous method and callback was unsupported. #242

Closed
LiaoPeng opened this issue Sep 5, 2018 · 2 comments
Closed

Anonymous method and callback was unsupported. #242

LiaoPeng opened this issue Sep 5, 2018 · 2 comments

Comments

@LiaoPeng
Copy link
Contributor

LiaoPeng commented Sep 5, 2018

The below code:

function some_func(x: u64, y: u64): u64 {
    let operator: (t: u64) =>u64 = function(y: u64): u64 {
       let res = y + x;
       return res;
    };
   return operator(y) + x;
 }

 assert(some_func(12,12) == 36);

It throw the below error:

TS2304: Cannot find name 'x'.

          let res = y + x;
                        ~
   in anonymous.ts(4,21)


  Error: Compile error

Expected that using x in the operator function.

@LiaoPeng LiaoPeng changed the title not support anonymous method and callback Anonymous method and callback was unsupported. Sep 5, 2018
@dcodeIO
Copy link
Member

dcodeIO commented Sep 9, 2018

Background is that closures are not yet supported because there is no respective representation in WASM. Afaik this is usually solved through GC support, i.e. by binding a scope to a concrete instance of a function.

@dcodeIO
Copy link
Member

dcodeIO commented Feb 7, 2019

Closing as this requires the concept of closures in general, which should have one or two tracking issues somewhere.

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