Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: Expected scope (6, _), found scope (7, _) #3205

Closed
softwareCobbler opened this issue Jul 1, 2023 · 0 comments
Closed

panic: Expected scope (6, _), found scope (7, _) #3205

softwareCobbler opened this issue Jul 1, 2023 · 0 comments

Comments

@softwareCobbler
Copy link

I recently upgraded an old project to 0.18.11 and got hit with

panic: Expected scope (6, _), found scope (7, _)

It bisects down to changes introduced from 0.17.5->0.17.6, and starting with 17.6 seems to be consistently present until now.
The following contrived case is enough to reproduce the error:

(() => {
    const enum E { a };
    () => E.a
})

Some output showing behavior across versions:

C:\Users\anon\dev\esbuild-bug>npm install esbuild@0.17.5
C:\Users\anon\dev\esbuild-bug>npx esbuild --version
0.17.5

C:\Users\anon\dev\esbuild-bug>npx esbuild Repro.ts
() => {
  let E;
  ((E2) => {
    E2[E2["a"] = 0] = "a";
  })(E || (E = {}));
  ;
  () => 0 /* a */;
};

C:\Users\anon\dev\esbuild-bug>npm install esbuild@0.17.6
C:\Users\anon\dev\esbuild-bug>npx esbuild --version
0.17.6

C:\Users\anon\dev\esbuild-bug>npx esbuild Repro.ts
X [ERROR] panic: Expected scope (6, 14) in Repro.ts, found scope (7, 39) (while parsing "Repro.ts")

  debug.Stack (runtime/debug/stack.go:24)
  helpers.PrettyPrintedStack (internal/helpers/stack.go:9)
  bundler.parseFile.func1 (internal/bundler/bundler.go:189)
  panic (runtime/panic.go:884)
  js_parser.Parse.func1 (internal/js_parser/js_parser.go:15411)
  panic (runtime/panic.go:884)
  js_parser.(*parser).pushScopeForVisitPass (internal/js_parser/js_parser.go:7635)
  js_parser.(*parser).visitAndAppendStmt (internal/js_parser/js_parser.go:10154)
  js_parser.(*parser).visitStmts (internal/js_parser/js_parser.go:7931)
  js_parser.(*parser).visitStmtsAndPrependTempRefs (internal/js_parser/js_parser.go:7848)
  js_parser.(*parser).visitExprInOut (internal/js_parser/js_parser.go:14352)
  js_parser.(*parser).visitExpr (internal/js_parser/js_parser.go:11681)
  js_parser.(*parser).visitAndAppendStmt (internal/js_parser/js_parser.go:9740)
  js_parser.(*parser).visitStmts (internal/js_parser/js_parser.go:7960)
  js_parser.(*parser).visitStmtsAndPrependTempRefs (internal/js_parser/js_parser.go:7848)
  js_parser.(*parser).appendPart (internal/js_parser/js_parser.go:15291)
  js_parser.Parse (internal/js_parser/js_parser.go:15583)
  cache.(*JSCache).Parse (internal/cache/cache_ast.go:170)
  bundler.parseFile (internal/bundler/bundler.go:215)
  bundler.(*scanner).maybeParseFile (internal/bundler/bundler.go:1360)

Node.js v18.16.0

C:\Users\anon\dev\esbuild-bug>npm install esbuild@0.18.11
C:\Users\anon\dev\esbuild-bug>npx esbuild --version
0.18.11

C:\Users\anon\dev\esbuild-bug>npx esbuild Repro.ts
X [ERROR] panic: Expected scope (6, 14) in Repro.ts, found scope (7, 39) (while parsing "Repro.ts")

  debug.Stack (runtime/debug/stack.go:24)
  helpers.PrettyPrintedStack (internal/helpers/stack.go:9)
  bundler.parseFile.func1 (internal/bundler/bundler.go:189)
  panic (runtime/panic.go:884)
  js_parser.Parse.func1 (internal/js_parser/js_parser.go:16240)
  panic (runtime/panic.go:884)
  js_parser.(*parser).pushScopeForVisitPass (internal/js_parser/js_parser.go:8090)
  js_parser.(*parser).visitAndAppendStmt (internal/js_parser/js_parser.go:10668)
  js_parser.(*parser).visitStmts (internal/js_parser/js_parser.go:8387)
  js_parser.(*parser).visitStmtsAndPrependTempRefs (internal/js_parser/js_parser.go:8303)
  js_parser.(*parser).visitExprInOut (internal/js_parser/js_parser.go:14613)
  js_parser.(*parser).visitExpr (internal/js_parser/js_parser.go:12251)
  js_parser.(*parser).visitAndAppendStmt (internal/js_parser/js_parser.go:10209)
  js_parser.(*parser).visitStmts (internal/js_parser/js_parser.go:8416)
  js_parser.(*parser).visitStmtsAndPrependTempRefs (internal/js_parser/js_parser.go:8303)
  js_parser.(*parser).appendPart (internal/js_parser/js_parser.go:16120)
  js_parser.Parse (internal/js_parser/js_parser.go:16452)
  cache.(*JSCache).Parse (internal/cache/cache_ast.go:170)
  bundler.parseFile (internal/bundler/bundler.go:215)
  bundler.(*scanner).maybeParseFile (internal/bundler/bundler.go:1360)
@evanw evanw closed this as completed in aad8818 Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant