#1143 js: Method.call fails for some core types

katox Sat 10 Jul 2010

Current js introspection implementation seems to have some limitations. For example sys::Method

t := Int#
x := t.method("plus")
y := x.func
z := z.call(1,2)sys::Int

produces

Uncaught TypeError: Object sys::Int.plus has no method 'func'. 

Under JVM it works as expected (z is 3). Rewriting as Int#plus gives the same outcome.

I use func for event callback sharing - is there a workaround?

katox Sat 10 Jul 2010

I found out that the workaround for callbacks is to create a closure and assign it to a slot.

Class X
{
  |Int,Int -> Int| cb

  new make()
  {
    cb = |Int x,Int y->Int| { x+y }
  }
}   

andy Sat 10 Jul 2010

Promoted to ticket #1143 and assigned to andy

Yes, the Method.func work is incomplete.

andy Sat 10 Jul 2010

Renamed from JS introspection to js: Method.func implementation incomplete

qualidafial Thu 16 Feb 2012

Ping. Is this still broken?

andy Thu 16 Feb 2012

Renamed from js: Method.func implementation incomplete to js: Method.call fails for some core types

andy Thu 16 Feb 2012

Ticket resolved in 1.0.62

Looks like I just fixed this while fixing something else ;)

Issue was actually that some types (like Int) are handled specially since they are backed by a real JavaScript type, and Method.call was not correctly handling that.

Fixed in changeset.

Login or Signup to reply.