Bug 105922 - CommaExpression with 'arguments' as last expression throws SyntaxError instead of ReferenceError
Summary: CommaExpression with 'arguments' as last expression throws SyntaxError instea...
Status: UNCONFIRMED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-02 07:35 PST by André Bargull
Modified: 2013-01-07 11:47 PST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description André Bargull 2013-01-02 07:35:28 PST
test case:
---
(function(){"use strict"; (1,arguments)=0 })
---

The `Comma Operator` [11.14] calls `GetValue` on its operands, therefore the conditions listed in 11.13.1 are not fulfilled. In particular that means the left-hand-side of the assignment is never of type `Reference`. Instead of a SyntaxError, it should rather be an early ReferenceError, if those were implemented in JSC.
Comment 1 Oliver Hunt 2013-01-07 10:49:00 PST
I'm not sure why this is a bug - reference errors are late errors, syntax errors are early.  Assigning to arguments in strict mode is a SyntaxError.  How are you determining that ReferenceError takes priority?

I also would have thought that var a; (1,a) = 0; would be a syntax error in strict mode as well.
Comment 2 André Bargull 2013-01-07 11:47:28 PST
Per [11.13.1] a SyntaxError is thrown iff
- Type(lref) is Reference is true
- IsStrictReference(lref) is true
- Type(GetBase(lref)) is Environment Record
- GetReferencedName(lref) is either "eval" or "arguments"


In the expression `(1,arguments)=0`, `Type(lref)` is not a Reference, but a value, therefore the strict-mode assignment to arguments rule in [11.13.1] does not apply, hence no SyntaxError. That means step 5 of [11.13.1] gets executed, PutValue(V,W) [8.7.2] will be called and then a ReferenceError gets thrown in step 1 of [8.7.2]. Per [16 Errors], the assignment `(1,arguments)=0` should result in an early error (with type ReferenceError? The spec does not mandate a specific error..?), but early errors for assignments are not implemented in JSC. (Strict mode is irrelevant for early errors in assignment expressions if the left-hand-side is not of type reference.)

As of now, the supplied test case results in an early SyntaxError.