aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-05-18 14:07:51 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-05-18 14:07:51 -0700
commit904bf17a5171eb9b450c5cada6450fed348c6358 (patch)
tree216c5555d60e0eb5a36f4b4e2b00fea34335ee82 /src
parente0e32986c76abc18a51041ddf14e339ba1cd0eb0 (diff)
downloadbun-904bf17a5171eb9b450c5cada6450fed348c6358.tar.gz
bun-904bf17a5171eb9b450c5cada6450fed348c6358.tar.zst
bun-904bf17a5171eb9b450c5cada6450fed348c6358.zip
Fix label parsing
Former-commit-id: 1c808594317e02f9f25abbdc81f7f734fd7e39f7
Diffstat (limited to 'src')
-rw-r--r--src/js_parser/js_parser.zig4
-rw-r--r--src/test/fixtures/label-continue-break-bug.js134
2 files changed, 11 insertions, 127 deletions
diff --git a/src/js_parser/js_parser.zig b/src/js_parser/js_parser.zig
index a60765c47..2d1f78ba3 100644
--- a/src/js_parser/js_parser.zig
+++ b/src/js_parser/js_parser.zig
@@ -1491,7 +1491,7 @@ const ParseStatementOptions = struct {
is_name_optional: bool = false, // For "export default" pseudo-statements,
is_typescript_declare: bool = false,
- pub fn hasNoDecorators(self: *ParseStatementOptions) bool {
+ pub fn hasDecorators(self: *ParseStatementOptions) bool {
const decs = self.ts_decorators orelse return false;
return decs.values.len > 0;
}
@@ -4057,7 +4057,7 @@ pub const P = struct {
if (is_identifier) {
switch (expr.data) {
.e_identifier => |ident| {
- if (p.lexer.token == .t_colon and opts.hasNoDecorators()) {
+ if (p.lexer.token == .t_colon and !opts.hasDecorators()) {
_ = try p.pushScopeForParsePass(.label, loc);
defer p.popScope();
diff --git a/src/test/fixtures/label-continue-break-bug.js b/src/test/fixtures/label-continue-break-bug.js
index 12e46cca3..ea6ba8885 100644
--- a/src/test/fixtures/label-continue-break-bug.js
+++ b/src/test/fixtures/label-continue-break-bug.js
@@ -1,125 +1,9 @@
-Object.assign(Interpolant.prototype, {
- evaluate: function (t) {
- var pp = this.parameterPositions,
- i1 = this._cachedIndex,
- t1 = pp[i1],
- t0 = pp[i1 - 1];
-
- validate_interval: {
- seek: {
- var right;
-
- linear_scan: {
- //- See http://jsperf.com/comparison-to-undefined/3
- //- slower code:
- //-
- //- if ( t >= t1 || t1 === undefined ) {
- forward_scan: if (!(t < t1)) {
- for (var giveUpAt = i1 + 2; ; ) {
- if (t1 === undefined) {
- if (t < t0) break forward_scan;
-
- // after end
-
- i1 = pp.length;
- this._cachedIndex = i1;
- return this.afterEnd_(i1 - 1, t, t0);
- }
-
- if (i1 === giveUpAt) break; // this loop
-
- t0 = t1;
- t1 = pp[++i1];
-
- if (t < t1) {
- // we have arrived at the sought interval
- break seek;
- }
- }
-
- // prepare binary search on the right side of the index
- right = pp.length;
- break linear_scan;
- }
-
- //- slower code:
- //- if ( t < t0 || t0 === undefined ) {
- if (!(t >= t0)) {
- // looping?
-
- var t1global = pp[1];
-
- if (t < t1global) {
- i1 = 2; // + 1, using the scan for the details
- t0 = t1global;
- }
-
- // linear reverse scan
-
- for (var giveUpAt = i1 - 2; ; ) {
- if (t0 === undefined) {
- // before start
-
- this._cachedIndex = 0;
- return this.beforeStart_(0, t, t1);
- }
-
- if (i1 === giveUpAt) break; // this loop
-
- t1 = t0;
- t0 = pp[--i1 - 1];
-
- if (t >= t0) {
- // we have arrived at the sought interval
- break seek;
- }
- }
-
- // prepare binary search on the left side of the index
- right = i1;
- i1 = 0;
- break linear_scan;
- }
-
- // the interval is valid
-
- break validate_interval;
- } // linear scan
-
- // binary search
-
- while (i1 < right) {
- var mid = (i1 + right) >>> 1;
-
- if (t < pp[mid]) {
- right = mid;
- } else {
- i1 = mid + 1;
- }
- }
-
- t1 = pp[i1];
- t0 = pp[i1 - 1];
-
- // check boundary cases, again
-
- if (t0 === undefined) {
- this._cachedIndex = 0;
- return this.beforeStart_(0, t, t1);
- }
-
- if (t1 === undefined) {
- i1 = pp.length;
- this._cachedIndex = i1;
- return this.afterEnd_(i1 - 1, t0, t);
- }
- } // seek
-
- this._cachedIndex = i1;
-
- this.intervalChanged_(i1, t0, t1);
- } // validate_interval
-
- return this.interpolate_(i1, t0, t, t1);
- },
-});
+label_name: {
+ break label_name;
+}
+
+while_label: while (true) {
+ for_label: for (let i = 0; i < 100; i++) {
+ continue while_label;
+ }
+}