Skip to content

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

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

(@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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions