Closed
Bug 1379717
Opened 7 years ago
Closed 7 years ago
Throw TypeError when accessing "caller/arguments" properties on accessor methods
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla56
Tracking | Status | |
---|---|---|
firefox56 | --- | fixed |
People
(Reporter: anba, Assigned: anba)
References
Details
Attachments
(1 file)
7.17 KB,
patch
|
shu
:
review+
|
Details | Diff | Splinter Review |
Test case 1: --- var o = { get m(){} }; var g = Object.getOwnPropertyDescriptor(o, "m").get; print(g.arguments); --- Test case 2: --- var o = { get m(){} }; var g = Object.getOwnPropertyDescriptor(o, "m").get; print(g.caller); --- Expected: Both test cases throw a TypeError Actual: No error thrown JSC/V8 throw a TypeError, Chakra doesn't.
Assignee | ||
Comment 1•7 years ago
|
||
I didn't want to add yet another condition to the IsNewerTypeFunction() function, when we could simply branch on the function kind instead.
Attachment #8884952 -
Flags: review?(shu)
Comment 2•7 years ago
|
||
(In reply to André Bargull from comment #0) > Test case 2: > --- > var o = { get m(){} }; > var g = Object.getOwnPropertyDescriptor(o, "m").get; > print(g.caller); > --- > > Expected: Both test cases throw a TypeError > Actual: No error thrown > > JSC/V8 throw a TypeError, Chakra doesn't. Isn't that only supposed to throw on strict mode?
Comment 3•7 years ago
|
||
Doesn't the first item in Forbidden Extensions[1] explicitly say that no such properties must be added, regardless of whether the code is in strict mode or not? [1] https://tc39.github.io/ecma262/#sec-forbidden-extensions
Assignee | ||
Comment 4•7 years ago
|
||
(In reply to Nicolas B. Pierron [:nbp] from comment #2) > (In reply to André Bargull from comment #0) > > Test case 2: > > --- > > var o = { get m(){} }; > > var g = Object.getOwnPropertyDescriptor(o, "m").get; > > print(g.caller); > > --- > > > > Expected: Both test cases throw a TypeError > > Actual: No error thrown > > > > JSC/V8 throw a TypeError, Chakra doesn't. > > Isn't that only supposed to throw on strict mode? ES6 added a new restriction that any function form except for FunctionDeclaration and FunctionExpression must not be created with own "arguments" and "caller" properties (https://tc39.github.io/ecma262/#sec-forbidden-extensions). But since SpiderMonkey implements these legacy properties as accessors (*), we need to 'translate' this restriction into throwing a TypeError when the accessors are called with anything besides FunctionDeclaration and FunctionExpression. (*) This is an ongoing experiment for TC39, in case TC39 decides to spec these legacy properties.
Comment 5•7 years ago
|
||
Comment on attachment 8884952 [details] [diff] [review] bug1379717.patch Review of attachment 8884952 [details] [diff] [review]: ----------------------------------------------------------------- Nice job expanding out the test.
Attachment #8884952 -
Flags: review?(shu) → review+
Assignee | ||
Comment 6•7 years ago
|
||
Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=7e537243fed2613487c724651f0b7e7473ed83eb
Keywords: checkin-needed
Pushed by ryanvm@gmail.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/3bceabbf445d Throw TypeError when accessing caller/arguments on accessor method. r=shu
Keywords: checkin-needed
Comment 8•7 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/3bceabbf445d
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
status-firefox56:
--- → fixed
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla56
You need to log in
before you can comment on or make changes to this bug.
Description
•