Self-hosted built-in functions should behave like non-strict functions with respect to .arguments and .caller

RESOLVED DUPLICATE of bug 929642

Status

()

RESOLVED DUPLICATE of bug 929642
4 years ago
4 years ago

People

(Reporter: 446240525, Assigned: Waldo)

Tracking

Trunk
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

4 years ago
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2106.0 Safari/537.36

Steps to reproduce:

js> String.fromCharCode.caller
null
js> String.fromCodePoint.caller
typein:37:0 TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
js> [].slice.arguments
null
js> [].map.arguments
typein:39:0 TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them


Actual results:

Related: bug 995200 - Enable strict mode for self-hosted code in opt builds, too

V8 has the same issue.
(Reporter)

Comment 1

4 years ago
Created attachment 8466348 [details] [diff] [review]
bug1047543.patch
Thanks for reporting this! It is indeed rather strange...

Till, shouldn't standard library functions behave the same whether they're self hosted or not?
Flags: needinfo?(till)
(Assignee)

Comment 3

4 years ago
Comment on attachment 8466348 [details] [diff] [review]
bug1047543.patch

I think you're right about this patch making behavior consistent.  But as I recall, the ES6 behavior is supposed to be that of the self-hosted builtins, so this patch goes the wrong way.
Attachment #8466348 - Flags: review-
Flags: needinfo?(till)
(Assignee)

Comment 4

4 years ago
Created attachment 8467343 [details] [diff] [review]
Builtin functions should behave like strict mode functions, wrt arguments/caller being poison pills

So this is a fix, sort of.  But recent ES6 drafts apparently make the poison pills configurable, so this isn't actually quite up-to-date.

And then, in talking on IRC with people today, I found out that there was even *more recent* consensus on making Function.prototype.{arguments,caller} into poison pills, then having non-strict, non-bound, etc. functions have instance accessors to provide legacy-compat behavior.

Then in further discussion, I mentioned bug 969478 would have put all legacy behavior (and strict/bound semantics, when called on such functions) into Function.prototype-homed accessors, while still having resolved poison-pills on strict/bound functions.  jorendorff proposes a larger experiment: move *all* behavior everywhere into Function.prototype-homed accessors, don't have poison pills anywhere at all.  It's worth an experiment, at least.  So I'm going to do that first.  Changing the behavior of natives overall, for consistency as this bug wants, can be deferred until that experiment completes.
(Assignee)

Updated

4 years ago
Assignee: nobody → jwalden+bmo
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
(Assignee)

Comment 5

4 years ago
I think we can probably lump this into the existing bug at this point.
Status: ASSIGNED → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → DUPLICATE
Summary: Self-hosted built-in functions should behave like non-strict functions → Self-hosted built-in functions should behave like non-strict functions with respect to .arguments and .caller
Duplicate of bug: 929642
You need to log in before you can comment on or make changes to this bug.