Skip to content

Commit

Permalink
release notes for #1671
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Oct 13, 2021
1 parent bc0a14a commit ae48978
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,29 @@

This fix was contributed by [@eelco](https://github.com/eelco).

* Fix an incorrect duplicate label error ([#1671](https://github.com/evanw/esbuild/pull/1671))

When labeling a statement in JavaScript, the label must be unique within the enclosing statements since the label determines the jump target of any labeled `break` or `continue` statement:

```js
// This code is valid
x: y: z: break x;

// This code is invalid
x: y: x: break x;
```

However, an enclosing label with the same name *is* allowed as long as it's located in a different function body. Since `break` and `continue` statements can't jump across function boundaries, the label is not ambiguous. This release fixes a bug where esbuild incorrectly treated this valid code as a syntax error:

```js
// This code is valid, but was incorrectly considered a syntax error
x: (() => {
x: break x;
})();
```

This fix was contributed by [@nevkontakte](https://github.com/nevkontakte).

## 0.13.4

* Fix permission issues with the install script ([#1642](https://github.com/evanw/esbuild/issues/1642))
Expand Down
4 changes: 3 additions & 1 deletion internal/js_parser/js_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1902,8 +1902,10 @@ func TestLabels(t *testing.T) {

expectPrinted(t, "x: y: z: 1", "x:\n y:\n z:\n 1;\n")
expectPrinted(t, "x: 1; y: 2; x: 3", "x:\n 1;\ny:\n 2;\nx:\n 3;\n")
expectPrinted(t, "x: (() => { x: 1; })()", "x:\n (() => {\n x:\n 1;\n })();\n")
expectPrinted(t, "x: ({ f() { x: 1; } }).f()", "x:\n ({ f() {\n x:\n 1;\n } }).f();\n")
expectPrinted(t, "x: (function() { x: 1; })()", "x:\n (function() {\n x:\n 1;\n })();\n")
expectParseError(t, "x: y: x: 1", "<stdin>: error: Duplicate label \"x\"\n<stdin>: note: The original label \"x\" is here\n")
expectPrinted(t, "x: (function(){ x: 1; })()", "x:\n (function() {\n x:\n 1;\n })();\n")
}

func TestArrow(t *testing.T) {
Expand Down

0 comments on commit ae48978

Please sign in to comment.