Closed Bug 1340148 Opened 7 years ago Closed 7 years ago

Redeclaration of top-level functions should throw SyntaxError in modules

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla54
Tracking Status
firefox54 --- fixed

People

(Reporter: anba, Assigned: anba)

References

Details

Attachments

(1 file, 1 obsolete file)

Test case:
---
function f() {}
var f;
---

Expected: Throws SyntaxError
Actual: No error
Attached patch bug1340148.patch (obsolete) — Splinter Review
Adding a new DeclarationKind entry seems to be the easiest way to handle this early error restriction.
Assignee: nobody → andrebargull
Status: NEW → ASSIGNED
Attachment #8841099 - Flags: review?(jcoppeard)
Spec bits:

https://tc39.github.io/ecma262/#sec-module-semantics-static-semantics-early-errors
15.2.1.1 Static Semantics: Early Errors
- It is a Syntax Error if the LexicallyDeclaredNames of ModuleItemList contains any duplicate entries. 


https://tc39.github.io/ecma262/#sec-module-semantics-static-semantics-lexicallydeclarednames
15.2.1.11 Static Semantics: LexicallyDeclaredNames
- ModuleItem:StatementListItem
    Return LexicallyDeclaredNames of StatementListItem. 

(Also NOTE 2 in 15.2.1.11)


https://tc39.github.io/ecma262/#sec-block-static-semantics-lexicallydeclarednames
13.2.5 Static Semantics: LexicallyDeclaredNames
- StatementListItem:Declaration
    Return the BoundNames of Declaration.
Comment on attachment 8841099 [details] [diff] [review]
bug1340148.patch

Review of attachment 8841099 [details] [diff] [review]:
-----------------------------------------------------------------

I love the exhaustive test.
Attachment #8841099 - Flags: review?(jcoppeard) → review+
Attached patch bug1340148.patchSplinter Review
Updated patch to apply cleanly on inbound, carrying r+ from jonco.
Attachment #8841099 - Attachment is obsolete: true
Attachment #8841544 - Flags: review+
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/1bc4a653e92e
Disallow function redeclarations at module top level. r=jonco
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/1bc4a653e92e
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla54
You need to log in before you can comment on or make changes to this bug.