Skip to content

newObj not using the right constructor #3

Closed
davidfletcher opened this Issue Jul 8, 2012 · 4 comments

4 participants

@davidfletcher

I was trying to use newObj "Image" to get an HTML Image object, but the object that was created wasn't a proper Image. It was an object but it was mostly empty.

I think the problem is in primMkObj - it's doing

return new primGetCtor(nm);

I think what's happening is the new here is treating primGetCtor itself as the constructor function, and the actual constructor that primGetCtor returns is just being ignored.

I can fix it by adding parentheses:

return new (primGetCtor(nm))
@rubendg
rubendg commented Jul 20, 2012

I think what you are trying to do is:

foreign import js "new Image()"
newImage :: IO a

This is equivalent to: "new Image()".

@atzedijkstra
UU CS Department member

I have modified the def of primMkObj, added the parenthesis.

@spockz
UU CS Department member
spockz commented Aug 27, 2012

@davidfletcher: can you confirm that it works now as you intended?

@davidfletcher

Yes, looks like it works now - thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.