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

Implicit closure for method doesn't handle named parameters #854

Closed
munificent opened this issue Dec 14, 2011 · 3 comments
Closed

Implicit closure for method doesn't handle named parameters #854

munificent opened this issue Dec 14, 2011 · 3 comments

Comments

@munificent
Copy link
Member

This works:
  foo(arg, [optional]) => print(arg); // <- Function, not method.
  invoke(callback, arg) => callback(arg);
  main() => invoke(foo, 'function');

So does this:
  invoke(callback, arg) => callback(arg);
  class Bar {
    foo(arg) => print(arg); // <- No optional param.
    bar() => invoke(foo, 'method');
  }

  main() => new Bar().bar();

But this does not:
  invoke(callback, arg) => callback(arg);
  class Bar {
    foo(arg, [optional]) => print(arg);
    bar() => invoke(foo, 'method');
  }

  main() => new Bar().bar();

It raises:

  node.js:134
          throw e; // process.nextTick error, or 'error' event on first tick
          ^
  ReferenceError: ClosureArgumentMismatchException is not defined

@jmesserly
Copy link

This is pretty much the same underlying issue as this:
http://code.google.com/p/dart/issues/detail?id=282

Runtime optional param info is only being attached to methods. Lambdas, implicit closures, and natives don't get it.


Marked this as being blocked by #282.

@rakudrama
Copy link
Member

Implicit binders would have it if it was possible to look into the result of Function.prototype.bind

I suggest replacing the binding-getter calls like
  Bar.prototype.foo$getter = function () {
    return this.foo.bind(this);
  }
with
  Bar.prototype.foo$getter = function () {
    return $bind$N(this.foo, this);
  }
or
  Bar.prototype.foo$getter = function () {
    return $bind$N$optional(this.foo, this);
  }

where N is the natural arity, and the ...$optional variants copy the $optional from the function to the result of binding.

@sigmundch
Copy link
Member

Fixed in r6850. 282 still needs fixing.


Added Fixed label.
Unmarked this as being blocked by #-282.

This issue was closed.
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

4 participants