microsoft / microsoft/TypeScript

Crash: malformed `super` destructuring in a decorated class static block panics

Open
#63,964 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Bug
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

### 🔎 Search Terms

visitArrayAssignmentElement, esDecorator super destructuring, static block decorator crash, IsArrayBindingOrAssignmentElement, "Debug failure. False expression"

### 🕗 Version & Regression Information

- This is a crash
- This changed between TypeScript 6.0.3 (JS) and 7.1.0-dev (`main`, Go): 6.0.3 reports `error TS1005` and exits but the Go rewrite panics

### ⏯ Playground Link

I cannot provide a link because the TypeScript playground does not have v7.

### 💻 Code

```ts
(@c
class extends B{static{[super.x 0]=[1];}});
```

### 🙁 Actual behavior

```
panic: Debug failure. False expression. [recovered, repanicked]

goroutine 50 [running]:
sync.(*WaitGroup).Go.func1.1()
sync/waitgroup.go:251 +0x48
panic({0x1061c58e0?, 0x176c0104340?})
runtime/panic.go:860 +0x12c
github.com/microsoft/TypeScript/tsc/internal/debug.Fail(...)
github.com/microsoft/TypeScript/tsc/internal/debug/debug.go:14
github.com/microsoft/TypeScript/tsc/internal/debug.assertSlow(...)
github.com/microsoft/TypeScript/tsc/internal/debug/debug.go:60 +0x5c
github.com/microsoft/TypeScript/tsc/internal/debug.Assert(...)
github.com/microsoft/TypeScript/tsc/internal/debug/debug.go:49
github.com/microsoft/TypeScript/tsc/internal/transformers/estransforms.(*esDecoratorTransformer).visitArrayAssignmentElement(...)
github.com/microsoft/TypeScript/tsc/internal/transformers/estransforms/esdecorator.go:2201 +0x90
github.com/microsoft/TypeScript/tsc/internal/ast.(*NodeVisitor).VisitSlice(...)
github.com/microsoft/TypeScript/tsc/internal/ast/visitor.go:171 +0x19c
github.com/microsoft/TypeScript/tsc/internal/ast.(*NodeVisitor).VisitNodes(...)
github.com/microsoft/TypeScript/tsc/internal/ast/visitor.go:99 +0x3c
github.com/microsoft/TypeScript/tsc/internal/transformers/estransforms.(*esDecoratorTransformer).visitAssignmentPattern(...)
github.com/microsoft/TypeScript/tsc/internal/transformers/estransforms/esdecorator.go:2281 +0x58
github.com/microsoft/TypeScript/tsc/internal/transformers/estransforms.(*esDecoratorTransformer).visitBinaryExpression(...)
github.com/microsoft/TypeScript/tsc/internal/transformers/estransforms/esdecorator.go:1915 +0x5b4
... 36 lines truncated ...
github.com/microsoft/TypeScript/tsc/internal/transformers/estransforms.(*esDecoratorTransformer).visitClassStaticBlockDeclaration(...)
github.com/microsoft/TypeScript/tsc/internal/transformers/estransforms/esdecorator.go:1538 +0x2f0
github.com/microsoft/TypeScript/tsc/internal/transformers/estransforms.(*esDecoratorTransformer).transformClassLike(...)
github.com/microsoft/TypeScript/tsc/internal/transformers/estransforms/esdecorator.go:705 +0xa60
github.com/microsoft/TypeScript/tsc/internal/transformers/estransforms.(*esDecoratorTransformer).visitClassExpression(...)
github.com/microsoft/TypeScript/tsc/internal/transformers/estransforms/esdecorator.go:1109 +0x138
... 108 lines truncated ...
github.com/microsoft/TypeScript/tsc/internal/compiler.(*emitter).emitJSFile(...)
github.com/microsoft/TypeScript/tsc/internal/compiler/emitter.go:200 +0x198
github.com/microsoft/TypeScript/tsc/internal/compiler.(*emitter).emit(...)
github.com/microsoft/TypeScript/tsc/internal/compiler/emitter.go:50 +0xec
github.com/microsoft/TypeScript/tsc/internal/compiler.(*Program).Emit.func2()
github.com/microsoft/TypeScript/tsc/internal/compiler/program.go:1851 +0x1c0
```

### 🙂 Expected behavior

The compiler should not crash 😊

### Additional information about the issue

**Disclosure:** This crash was found with a custom mutation fuzzer and AI assistance (Kimi K3). The input was minimized and then verified by hand against TypeScript 7.1.0-dev (`main`) and TypeScript 6.0.3.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in tsc/internal/transformers/estransforms/esdecorator.go at visitArrayAssignmentElement and follow its callers from visitAssignmentPattern while compiling the minimized decorated-class snippet. Verify that TypeScript 7.1.0-dev reports a diagnostic for the malformed super destructuring instead of panicking, matching the non-crashing behavior described for TypeScript 6.0.3.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, typescript
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.