Skip to content

Internal compiler errors on complex expressions, bug was briefly fixed only in TS 4.7.4 #62282

@na7ure-a

Description

@na7ure-a

🔎 Search Terms

Compiler regression
Duplicate identifier '(Missing)'
Complex nested ternary expression
Unreachable code detected
Reintroduced bug

🕗 Version & Regression Information

  • This is a peculiar bug concerning version 4.7.4. The provided code compiles successfully only in version 4.7.4

⏯ Playground Link

https://www.typescriptlang.org/zh/play/?target=7&ts=4.7.4#code/IYIwzgLgTsDGEAJYBthjAgwsglgRwFcBTBAbwCgEkB7AO0igPmqgAoATGAWzQC4FaBLiCJQANAgK0A7jjBF+rAJQIAvAD4EIatWRFgtFRSpUIACzkA6TsB4ZVCG3conzVqbPlrJMuURcAvi5OfAJCIlDkLh5+iioaWjp6BlFB5ABmUvA4dAhEtGYGsETsyvwAbtQ47AjkxjT0iGAADkSwOFz5-Nq6+rTe6cDI8gDcLnqIglAQBFAl-ILCot4AtADMAByWAEwArACMY1QTCBA4tDhEkPwAopBmogA8IDgA5ucQmg60RNIId+Yni93rRPqwAEJvACSoNYAHYAJxKCRTGZzdhKI6nc6XSDeM4XK4QLEIVisFptDr5BAAfmxhLxC1+JgBDygzzeH3UEOhsJWCO2yIQK12CMsADYNmslDLLK8YC0sWkUGgMKyngAlTREAAeEHy7Aw2HwxDILlgdAYTAgLFYnVocHmCA1EnSc1+OGQyAW4VERhcVDABFabHWAAZLLttmsJGVEr0DGpNPVjkREIx5cAIN0kn18YwiCSEHM0f1iwRM8SAyYAkpq24wJZ7Y6ag5m8V2PWLI23UQPV6Bu7ZF7Ai5206NVEqL3+96wktIlRMy1WGYWDgAF6Wn0LiTNVAQYD6H1epT8ABEzWAMFoVUN59qKYaeOabwmF6vN7vYAfDkv14Mb9zyLE4wFgWxOigexSTPBBKmqJNH2rVNEHA5AuB+dBFGaMMdwiMRmn2PDRAI7ZiKgeJNEWCJvDJVgpHYIh0nOEoEDQHwAGtb2kQw2IwDV9GYKDHgAQSgGAAE9HgYc5Xk0AAfeNkloCQXQQMTJOk6BZIU+caMUmTaDk2UbWocwJKLEw0Iwq4wEshAAiLMCINEMBlCLEtZjLV9XgmIs0ioC1aEqCS3M-bT2FeBRnVo+jaEY5ifhqdipC46geJUdiNRlfgGKYlj2CfTyoH6Mk8sS1iUtoNKMr4nwEoKusqDSNIPlEQZimdQSbWEgAFPI9QNDANOAKTDLkhBFJ6ZSJAALQkAB1Ab9Xi4bxNGrSoB0ya9OWAztKM5MXFM8zWGkOZID0dhyJRAgIH1a7dvEBBBgIZAzmQCTyNg6jRCnU5qE6NzmKum6kAVCwjNue4nmNQgiHUH7fUicg0hOOY5mAdhZP4OHTW+Zl1XZQQvW5EnkAkfZ9ksBENnFOtyBOMxZjocjvAx-RsaM6xuDQKIMiyM5ckzVa6Djaa8zqcY0wQVBLq+rROVBbxIVeGEIFYFZxThTFpcQEAmA47gcwTfoHGgYgsROV5iGQZozH4AS4B6sBRPWsaDomqbcwMCQ8aICRxq+Uk4oapK6tS7jeKy7qWFdkaPa2w6dol32sFweHA89xGsUyWhslydJRBtsAxdgonHn9zQpZMWWZYtZozlgXGM-x4tRE52SQJl2wiFwYBocBdkq+8H4-grqvWAbpuJHFMUpSRDy0y8qhe-7-ysQAek3hAAHkh7g1ycnodvmhYRBRCgOOEDZfwqGKssyTliBPpUR4Q4N2AjdsWkBGZKgK5OyEvHd2m1tre1Nn7VuAcEBB25DbPu9sJArAACwRilGGFQTI-gAJhuyIBLs3aaSDinH2Kl04mhgXAui5UCoR2qlHTK-FY7CQTmA5OECZoUMzrA7OQp9goMsHCOEGxZTjnYJYE6ZgJKsAQXbMwkjAZXFkbbe2iigaa22GKFBCIYx-3Hngyu0DuRlXivlcOVUarRyNNAoU2w4RCN0TKV0xcCCl1oMoIUci1E2g0SsOE2wdjinFCiQmhjJ6mLDpVDAkd0rWO4cQIUWsxTCJ1kKZmV9DAyjGKjcgQA

💻 Code

abstract class Clique {
  constructor(dramas: number, unwise: () => boolean) {
    this.dramas = dramas
    this.unwise = unwise
  }
  dramas: number

  unwise: () => boolean

}

function enhanced(): void 
{
  const specimen: boolean = false;
  let nurtured: number = -38.251;
  let tiniest: Esther<bigint> = new Esther<bigint>(BigInt(79), nurtured);
  tiniest = tiniest;
   ((specimen ? tiniest : new   Esther<bigint>(BigInt(-92), -59.683))).grasp;
  }

class Esther<R> extends Clique {
  constructor(menaced: R, freewill: number) {
    super(-30.523, (): boolean => {
    let rugrat: boolean = true;
    return  rugrat;
      })
    this.menaced = menaced
    this.freewill = freewill
  }
  menaced: R

  freewill: number
  grasp(horizons: number, plataea: null): "paranoids" 
{
    const piglet: "paranoids" = "paranoids";
    let scammers = (): void => 
{
      let calmness: (p0: number,p1: number,p2: number) => number = (((undefined as unknown) as Reactors<Array<string> | boolean, R, Array<string> | number | string>)).toothy;
       calmness;
      };
    scammers();
    return  piglet;
    }

  convoys(partridge: R = ((undefined as unknown) as R)): undefined{
    return ((undefined as unknown) as undefined)
  }

}

interface Reactors<P extends Array<string> | boolean, Z, W extends Array<string> | number | string> {
  toothy(wrestled: number, nutted: number, faultily: number): number

  tomes(filed: number, crashing: Esther<Clique>): number

}

let rereading: Clique = new Esther<null>(null, 11.986)

let huron: number = rereading.dramas


function grandson(): boolean 
{
  let lastly: bigint = BigInt(-67);
  let buckram: boolean = true;
  let guelph: Reactors<Array<string> | boolean, Clique, string> = ((undefined as unknown) as Reactors<Array<string> | boolean, Clique, string>);
  function ferguson(): Esther<Clique> 
{
    let coptic: Clique = rereading;
    let amelia: Esther<Clique> = new Esther<Clique>(coptic, 69.839);
    return  amelia;
    };
  // Other versions report errors here
  return  ((lastly) < ((buckram ? new   Esther<Reactors<Array<string> | boolean, Clique, string>>(guelph, -40.830) : new   Esther<Reactors<Array<string> | boolean, Clique, string>>(((undefined as unknown) as Reactors<Array<string> | boolean, Clique, string>), 14.778)).menaced.toothy(guelph.tomes(guelph.tomes(-29.493, new Esther<Clique>(((undefined as unknown) as Clique), 27.793)), ferguson()), guelph.tomes(-72.266, new Esther<Clique>(((undefined as unknown) as Clique), -69.777)), huron)));

}

🙁 Actual behavior

When compiling this code with any TypeScript version before or after 4.7.4 (e.g., 4.6.4, 4.8.4, and the latest nightly), the compiler produces a cascade of seemingly internal or incorrect errors, including multiple Duplicate identifier '(Missing)'. errors. These errors do not provide clear guidance on what is wrong with the code.

Example errors from a recent version:

  • Duplicate identifier '(Missing)'.
  • Unreachable code detected.
  • Type 'number' is not assignable to type 'boolean'.
  • And many other parsing/type-checking errors that seem to be a consequence of the initial failure.

🙂 Expected behavior

The code should compile successfully without errors, as it does in TypeScript version 4.7.4.

If the code is indeed invalid, the compiler should produce a clear and actionable error message pointing to the specific syntax or type issue, rather than internal-sounding errors like Duplicate identifier '(Missing)' which suggest a problem within the compiler's parser or checker. The fact that it compiles in one specific version strongly suggests this is a compiler bug.

Additional information about the issue

No response

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