Closed Bug 1310714 Opened 8 years ago Closed 8 years ago

We always execute self-hosted code as strict, and that's wrong.

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: emilio, Unassigned)

References

Details

When executing self-hosted, it's not always right to execute it in strict mode, since the behavior might change.

See bug 1304638, for example, which was exposed because of this: Array.prototype.sort shouldn't throw when accessing a frozen object in a non-strict script, yet we always do this.

Not sure which is the best way to fix this, seems like a pretty though bug, but also a pretty though fix.

Test case:

var a = Object.freeze([5, 5]);
a.sort(function() { });

Result: TypeError
Expected: No exception thrown, since the script is in non-strict mode.
This bug is invalid. Array.prototype.sort [1] is specified to throw a TypeError if any [[Set]] call returns `false`. 

[1] https://tc39.github.io/ecma262/#sec-array.prototype.sort
(In reply to André Bargull from comment #1)
> This bug is invalid. Array.prototype.sort [1] is specified to throw a
> TypeError if any [[Set]] call returns `false`. 
> 
> [1] https://tc39.github.io/ecma262/#sec-array.prototype.sort

Hmm, fair enough. I'll try to see if that can affect to other self-hosted code that sets any properties (since that spec reference seems particular to Array.prototype.sort, but this report is not), and otherwise resolve as invalid.

Thanks for the spec reference, I didn't expect something like that to be in the spec :)
Yeah, pretty much all our self-hosted functions that we implement and call Set(..) are defined in terms of Set(.., /* throws = */ true).

Sorry for the invalid report, FWIW I discussed with Till about this before opening it :P.

I'm not sure if there are other strict-mode behaviors that could affect this, but assuming there are not (feel free to reopen if that's not the case), then we're good here.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → INVALID
(In reply to Emilio Cobos Álvarez [:emilio] from comment #3)
> Sorry for the invalid report, FWIW I discussed with Till about this before
> opening it :P.

No need to be sorry. Participating and filing bug reports is always appreciated! :-)
(In reply to André Bargull from comment #4)
> No need to be sorry. Participating and filing bug reports is always
> appreciated! :-)

Thanks! At least this allowed me to discover bug 1310744, so meh, I guess it could have been worse :)
You need to log in before you can comment on or make changes to this bug.