Closed Bug 1231647 Opened 9 years ago Closed 9 years ago

Duplicate export check doesn't work for const and let bindings

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla46
Tracking Status
firefox46 --- fixed

People

(Reporter: jonco, Assigned: jonco)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

These are not currently added to the exportedNames list.

Let/const bindings will generate a SyntaxError if they duplicate the name of an existing binding, but this is not enough to catch all errors.
Patch to add exported let/const names to the exported names list and add tests.
Attachment #8697245 - Flags: review?(shu)
Comment on attachment 8697245 [details] [diff] [review]
check-duplicate-export-let

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

::: js/src/frontend/Parser.cpp
@@ +5052,5 @@
> +template<>
> +bool
> +Parser<SyntaxParseHandler>::addExportNamesForDeclaration(Node node)
> +{
> +    JS_ALWAYS_FALSE(abortIfSyntaxParser());

MOZ_ALWAYS_FALSE if you would

@@ +5276,5 @@
>          kid = lexicalDeclaration(YieldIsName, tt == TOK_CONST);
>          if (!kid)
>              return null();
> +        if (!addExportNamesForDeclaration(kid))
> +            return null();

Ah, good catch.

::: js/src/jit-test/tests/modules/duplicate-exports.js
@@ +30,5 @@
> +testSyntaxError("export let x, y, z; export let y;");
> +testSyntaxError("export const v = 0; export const v = 0;");
> +testSyntaxError("export const x = 0, y = 0, z = 0; export const y = 0;");
> +testSyntaxError("export var v; export let v;");
> +testSyntaxError("export var v; export const v = 0;");

Could you add one more case testing |export let v; export const v;|?
Attachment #8697245 - Flags: review?(shu) → review+
https://hg.mozilla.org/mozilla-central/rev/f6271cdfbdb9
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla46
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: