Redeclaration of top-level functions should throw SyntaxError in modules

RESOLVED FIXED in Firefox 54

Status

()

Core
JavaScript Engine
RESOLVED FIXED
11 months ago
11 months ago

People

(Reporter: anba, Assigned: anba)

Tracking

(Blocks: 1 bug)

Trunk
mozilla54
Points:
---

Firefox Tracking Flags

(firefox54 fixed)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

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

Expected: Throws SyntaxError
Actual: No error
(Assignee)

Comment 1

11 months ago
Created attachment 8841099 [details] [diff] [review]
bug1340148.patch

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)
(Assignee)

Comment 2

11 months ago
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 3

11 months ago
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+
(Assignee)

Comment 4

11 months ago
Created attachment 8841544 [details] [diff] [review]
bug1340148.patch

Updated patch to apply cleanly on inbound, carrying r+ from jonco.
Attachment #8841099 - Attachment is obsolete: true
Attachment #8841544 - Flags: review+

Comment 6

11 months ago
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

Comment 7

11 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/1bc4a653e92e
Status: ASSIGNED → RESOLVED
Last Resolved: 11 months ago
status-firefox54: affected → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla54
You need to log in before you can comment on or make changes to this bug.