-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Polyfilled Float32Array constructor cannot be stringified #300
Comments
Seems the problem not in polyfilled |
@zloirock Yes, it looks like E.g.
|
Did some digging on this in my debugger - ultimately core-js gets to here: return fn.apply(that, arguments); Where:
Which is ultimately equivalent to doing: Float32Array.prototype.toString.call(); Which ends in a TypeError. Unfortunately I wasn't able to trace what lead to the function getting called with zero arguments in the first place. The callstack gave no clues; |
@fatcerberus Good one. Actually, I was able to replicate this with just
It appears that |
Found something else suspicious. The whole module.exports = function(fn, that, length){
aFunction(fn);
if(that === undefined)return fn;
switch(length){
case 1: return function(a){
return fn.call(that, a);
};
case 2: return function(a, b){
return fn.call(that, a, b);
};
case 3: return function(a, b, c){
return fn.call(that, a, b, c);
};
}
return function(/* ...args */){
return fn.apply(that, arguments);
};
};
|
I tried setting a breakpoint in the outer factory function, but it didn't get hit. I'll see if I can get to the bottom of this later, it's quite a curious bug. |
As an experiment, I changed the offending line to: return fn.apply(that, [this].concat(Array.from(arguments))); Which caused this error:
|
What I've found out so far:
Unfortunately I've been unable to follow the logic that leads core-js to polyfill the function this way in the first place. 🙁 |
Regarding unwanted polyfill, I found that Without
And with
the error message becomes
Much less informative. |
Hm, can't reproduce that behavior in Node 7.10.0: require('core-js');
new Float32Array(new ArrayBuffer(8), 3);
The only thing I can think of is that you're using an older version of Node that's not fully standards compliant, triggering the polyfill. I indeed get the "wrong offset" error under Duktape, but not Node. |
@fatcerberus Yes, you are right, I ran this code in Node 6.10.3 (as opposed to the example listed in the OP which ran in 7.2.0), this is the reason why I've got different behaviour, but it still isn't clear why core-js decided that it should be polyfilled, node.green cannot explain that. |
@zloirock What was ultimately the problem? This bug was really crazy and I couldn't figure out what the cause was from the diff. |
@fatcerberus the problem was in |
how can this be fixed ? still got error in ie11 |
@Anoxy by using actual versions. If it does not help, please, create a new issue with a reproducible example. |
This
results in error:
While the same code without
core-js
works as expected:and outputs
Another problem is that
Float32Array
behaviour was changed for no obvious reason and started to make problems. This was totally uncalled for and wasn't easy to debug. Since current Node releases are considered virtually ES2015/ES2016-compliant, the one could reasonably assume thatrequire('core-js')
is the same thing as cherry-picking ES2017+ features - and this would be a mistake that may result in counter-intuitive issues like this one (#283 already addresses the problem with default polyfilling strategy).core-js 2.4.1
node 7.2.0
The text was updated successfully, but these errors were encountered: