-
Notifications
You must be signed in to change notification settings - Fork 570
Don't ignore array type for special JS array types #599
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
Conversation
js/js_test.go
Outdated
|
||
func instanceof(x interface{}, y *js.Object) bool { | ||
return js.Global.Call("$instanceof", x, y).Bool() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be a better way to do this test; I'm not sure what it would be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized that you added a new file for this. I'd prefer the eval
method of line 15 for this. Also, could you maybe try to add a function to dummys
that simply returns the parameter (thus externalizing the value) and then try .Get("constructor") != uint8Array
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A clever solution. Done.
compiler/prelude/prelude.go
Outdated
@@ -120,7 +120,7 @@ var $substring = function(str, low, high) { | |||
|
|||
var $sliceToArray = function(slice) { | |||
if (slice.$length === 0) { | |||
return []; | |||
return new slice.$array.constructor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we simply remove this special case? subarray
and slice
with a length of 0
should give the same result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested with that entirely removed at first, and it worked just as well. I wondered if the special case served as a meaningful optimization, so left it in there.
If you're in favor of removing it, that is of course fine with me. I can make that change.
Cool. Thanks the updates and for contributing in general. Merging. |
This PR should fix the problem mentioned in #597 .
Using this sample program:
Before:
After: