[P2] Interpreter: qualified globalThis.isNaN keeps strict Number.isNaN semantics for coercible arguments
I maintainer di solito rispondono entro 1 giorno
@nickna ci sta già lavorando.
Dal 27/10/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 75/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- csharp, typescript
Direzione di ricerca
Leggi il ramo name == "isNaN" in src/SharpTS/Runtime/Types/SharpTSGlobalThis.cs e la registrazione di isNaN in src/SharpTS/Runtime/BuiltIns/NumberBuiltIns.cs, quindi confrontali con il gestore globale di isNaN. Riproduci i casi segnalati usando l’interprete verificato; il lavoro è terminato quando sia isNaN sia globalThis.isNaN restituiscono true per undefined e per le stringhe non numeriche.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
In the checked interpreter, globalThis.isNaN(x) and bare isNaN(x) are not the same function for arguments that need numeric coercion. The qualified read resolves through the Number namespace static (src/SharpTS/Runtime/Types/SharpTSGlobalThis.cs, the name == "isNaN" branch returning GetStaticMethod("Number", name)), and that static requires args[0].Kind == ValueKind.Number before testing for NaN (src/SharpTS/Runtime/BuiltIns/NumberBuiltIns.cs, the .MethodV2("isNaN", ...) registration). It therefore answers false for every non-number, including coercible ones, while the bare global handler coerces.
For undefined and non-numeric strings the two readings disagree: bare isNaN(undefined) is true (also per #2695's interpreter output) while globalThis.isNaN(undefined) is false. Node gives true for both forms.
Measured reference (node v24.17.0, plain JS semantics):
> console.log(isNaN(undefined), globalThis.isNaN(undefined), isNaN("abc"), globalThis.isNaN("abc"))
true true true true
The interpreter's qualified result follows from the cited code path on main (99b51889); I could not execute the interpreter locally to capture its literal output for these arguments.
Expected Behavior
isNaN and globalThis.isNaN are the same function. ToNumber(undefined) is NaN and ToNumber("abc") is NaN, so both forms print true, matching Node.
Reproduction Steps
- Run the following through the checked interpreter:
console.log(isNaN(undefined as any), globalThis.isNaN(undefined as any));
console.log(isNaN("abc" as any), globalThis.isNaN("abc" as any));
- Expected per Node:
true true/true true. Current interpreter behavior: baretrue, qualifiedfalse(source-derived from the cited fallback; the qualifiedglobalThis.isNaN(null) → falseline in #2695's output is consistent with, but could not distinguish, the strict reading since both readings agree onnull).
Discovered During
Work on #2695 (bare global isNaN numeric coercion). Fixing the bare handler makes the bare/qualified divergence observable on coercible arguments. The qualified fallback is unchanged code on main; the divergence predates that fix.
Suggested Fix (unverified hypothesis)
Route the qualified isNaN read in src/SharpTS/Runtime/Types/SharpTSGlobalThis.cs to the same global handler the bare call uses, so both forms share the coercive path. parseInt/parseFloat/isFinite in the same branch may deserve the same check.
- Lingua principale
- C#
- Stelle
- 156
- Fork
- 4
- Merge medio
- 13h 33m
- PR unite (30g)
- 45
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nickna/SharpTS
-
bug priority: P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
bug priority: P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
bug priority: P2
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
I maintainer di solito rispondono entro 1 giorno
-
bug priority: P2
Difficoltà 4/5 3-5 giorni Idoneità per principianti 22/100
I maintainer di solito rispondono entro 1 giorno
-
bug priority: P2
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di nickna/SharpTS
Issue simili
-
area-blazor NativeAOT Regression
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
dotnet/aspnetcore#70236 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug evaluation required
Difficoltà 1/5 1-3 ore Idoneità per principianti 78/100
MaterialDesignInXAML/MaterialDesignInXamlToolkit#4118 ·
I maintainer di solito rispondono entro 1 giorno
-
documentation good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
[Format]: .dartApertaformats
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
KnifeLemon/Filee#980 ·
I maintainer di solito rispondono entro 1 giorno