Skip to content

Crash: when inferring from a tuple with middle rest elements and trailing variadic elements #63005

Open

Description

@na7ure-a

🔎 Search Terms

Internal Error: Debug Failure

Variadic tuple types crash

infer rest elements crash

tuple mapping crash

🕗 Version & Regression Information

Versions tested: 5.7.3, 5.8.3, 5.9.3, Nightly

⏯ Playground Link

https://www.typescriptlang.org/zh/play/?target=7&noEmit=true&ts=6.0.0-dev.20260117#code/PTAEAEGcBcCcEsDG0Bco4FcCmAoEEA7AewFEBbeVdWbPMWLAB1iNAGIBWARi4GYAOHNACejLKADKGAEYAVDIwBMAJSwwAggQAms2AEN4AG3gEA5gDU9CPVqSKAPLNBYAHtCzbIoDAQDWxAHcCAG0AXQA+UABeUCdXd09QYJxQVNAAOkyAChMAMyxYUABhAEowgBoUtMz0vILQACFnNw8tL2C9AmFyzu7EfUgAC1CcUNAq1IB+JKLymoaxidA0AiwANwKAbhwhUXEpOQUVNWhNHX0jEwsreBs7WRPoyRl5JVUNbV0DYzNLa1tEA5gjU9GgAAwVaRoLjlRBoRQRbZAA

💻 Code

// repro #51138
type SubTup2RestAndTrailingVariadic2<T extends unknown[]> = T extends [
    ...(infer C)[],
    ...infer B extends [any,any,crash]
] 
    ? [C,...B] 
    : never;

type SubTup2RestAndTrailingVariadic2Test = SubTup2RestAndTrailingVariadic2<[...a: 0[],b: 1,c: 2]>;

🙁 Actual behavior

.\ts-versions\nightly\node_modules\.bin\tsc.cmd  .\inferTypesWithFixedTupleExtendsAtVariadicPosition_m.ts
D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:123178
      throw e;
      ^

TypeError: Cannot read properties of undefined (reading 'aliasSymbol')
    at inferFromTypes (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:68512:18)                                                                                                  
    at inferFromObjectTypes (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:68994:21)                                                                                            
    at invokeOnce (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:68704:9)                                                                                                       
    at inferFromTypes (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:68666:11)                                                                                                  
    at inferTypes (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:68500:5)                                                                                                       
    at getConditionalType (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:62537:11)                                                                                              
    at getConditionalTypeInstantiation (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:63526:305)                                                                                
    at instantiateTypeWorker (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:63629:14)                                                                                           
    at instantiateTypeWithAlias (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:63566:20)                                                                                        
    at getTypeAliasInstantiation (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:60132:52)                                                                                       

Node.js v22.19.0

🙂 Expected behavior

The compiler should report a syntax error and not crash.

Additional information about the issue

No response

Activity

  1. changed the title [-]Compiler Crash when inferring from a tuple with middle rest elements and trailing variadic elements[/-] [+]Crash: when inferring from a tuple with middle rest elements and trailing variadic elements[/+] on Jan 18, 2026
  2. RyanCavanaugh commented on Jan 20, 2026

    @RyanCavanaugh
    Member

    🤖 Thank you for your issue! I've done some analysis to help get you started. This response is automatically generated; feel free to 👍 or 👎 this comment according to its usefulness.

    Similar Issues

    Here are the most similar issues I found

    If your issue is a duplicate of one of these, feel free to close this issue. Otherwise, no action is needed.

    Possibly Working as Intended

    It looks like this behavior might be intentional. Here's what a computer had to say about it.

    The pattern ...(infer C)[] is not legal tuple‐pattern syntax. A rest element may be written as ...infer C (optionally with a constraint such as ...infer C extends unknown[]), but it cannot be followed by []. The compiler should therefore issue a normal syntax or type error. Instead it dereferences an internal object and crashes, which is an internal compiler error. So the observed behavior is a compiler bug, not the correct or expected diagnostics.

  3. added a commit that references this issue on Mar 24, 2026
    469ba1f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: CrashesUnhandled exceptions/panics with no immediate primary root cause identifiedHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions