-
Notifications
You must be signed in to change notification settings - Fork 13k
Description
🔎 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
💻 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