Compiler: const enum import can use a same-named enum from another module

Aperta
#3,532 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
66/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp, typescript
Ambito
compilers

Direzione di ricerca

Start by tracing CompilationContext.ResolveEnumName and the emitting path that uses it; the issue identifies the simple-name EnumToModule fallback as the source of the collision. Use the three-file example in the issue and run the supplied --compile ... --verify command, then execute the output. Done means the compiled program prints 3 7, matching TypeScript's output.

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

Descrizione

bug

A same-named enum in an unrelated loaded module can supply the value for a compiled named import.

def.ts

export const enum E { A = 3 }

def-other.ts

const enum E { A = 7 }
export const other = E.A;

main.ts

import { E } from "./def";
import { other } from "./def-other";
console.log(E.A, other);

Strict TypeScript 6.0.3 accepts the three files. Its output prints 3 7 on Node v22.23.2. Both clean SharpTS cabb41636 and PR #3510 head 66d78c4ff pass complete saved-IL verification and print 7 7.

dotnet SharpTS.dll --no-tsconfig --compile main.ts -o main.dll --verify
dotnet main.dll

The clean CLI SHA256 is 5335B14C2A96172D0372D8FCDD75264741EB8A0B19C0273737C3BBF2967D3ACE. Found while reviewing #3510. CompilationContext.ResolveEnumName falls back to an EnumToModule table keyed by the enum's simple name. The emitting path should resolve the actual checked import and its source module. This example has no local binding shadow or string-index syntax. #3528 addresses the local-binding case and #1790 covers ordinary enum runtime bindings.

Lingua principale
C#
Stelle
156
Fork
4
Merge medio
15h 49m
PR unite (30g)
42

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.