[P2] Compiler: generic class-expression lexical super leaves constructor this unbound

Chiusa
#3,484 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Una pull request collegata è già stata integrata.

  • #3510 di @nickna — integrata

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
30/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
csharp, typescript
Ambito
backend, compilers

Direzione di ricerca

Start with the reported failure through $ClassDefinition.InitializeReceiver and the generic-owner guard; compare the behavior with the retained evidence in artifacts/p3-compiler/lexical-generic-boundary.ts, .log, .dll, and check-lexical-boundary-oracles.cjs. Reproduce the saved-IL execution failure and trace how lexical super() binds constructor this for generic class expressions. Done means the stated acceptance cases pass while complete saved-IL verification and native admission behavior are preserved.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug priority: P2

Generic class-expression constructors still leave this unbound when super() runs through a lexical arrow.

const C = class<T> extends class { constructor() {} } {
    value: T;
    constructor(value: T) {
        const initialize = () => super();
        initialize();
        this.value = value;
    }
};
console.log(new C<number>(7).value);

TypeScript 6.0.3 ES2022 transpilation executed by Node prints 7. SharpTS accepts this TypeScript source, saves the assembly, and passes complete IL verification, but executing it throws guest ReferenceError: Must call super constructor before accessing this through $ClassDefinition.InitializeReceiver.

Verified with the CLI built from the open P3 batch after the managed nongeneric element transport work for #3477. Evidence is retained in artifacts/p3-compiler/lexical-generic-boundary.ts, .log, .dll, and check-lexical-boundary-oracles.cjs. No introducing-commit claim is made.

This is distinct from #3477's nongeneric user-class field/accessor/private-brand and constructor-parameter transport. The existing generic-owner guard was deliberately retained: invoking a helper on an open generic CLR owner from a nongeneric arrow needs an explicit canonical closed-owner binding, not removal of the guard or reliance on raw reflection lookup.

Acceptance: generic class-expression lexical super binds the same constructor this cell, initializes own elements once, preserves current constructor parameter bindings and new.target, and retains complete saved-IL verification. Cover different closed instantiations and inherited generic owners without broadening native admission.

Lingua principale
C#
Stelle
156
Fork
4
Merge medio
16h 37m
PR unite (30g)
41

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nickna/SharpTS

Tutte le issue di nickna/SharpTS

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.