Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Some(U) of an @as(undefined) case compiles to undefined when U is a constant

Offen
#8,954 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
55/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
javascript
Bereich
compilers

Rechercherichtung

Start by reading rule 12 in compiler/ml/UntaggedVariants.md and tracing the constant handling in compiler/ml/lambda.ml, especially const_some_none_depth. Reproduce the example and compare Some(U) with None for the constant and function cases. Done means both comparisons show Some(U) differs from None, with compiler tests covering the regression.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Some(U), where U is an @as(undefined) case of an untagged variant, compiles to undefined when U is a constant argument, so it equals None.

@unboxed type u = | @as(undefined) U | V(string)
let x: option<u> = Some(U)                       // compiles to: let x = undefined;
@inline(never) let mk = (v: u): option<u> => Some(v)
Console.log2(x == None, mk(U) == None)

Output: true false. Through a function, Some(U) is boxed and differs from None; as a constant, it is undefined.

Expected: Some(U) differs from None in both cases. This is the example of #6222, which made option unboxing compatible with untagged variants.

A likely place is compiler/ml/lambda.ml, const_some_none_depth, which treats every Const_constructor as not none, including one whose literal is undefined. This cause is not confirmed. The rule is compiler/ml/UntaggedVariants.md rule 12, in #8952.

Vorherrschende Sprache
OCaml
Sterne
7.5k
Forks
483
Ø Merge
1 T. 1 Std.
Gemergte PRs (30 T.)
169

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus rescript-lang/rescript

Alle Issues in rescript-lang/rescript

Ähnliche Issues

Weitere Issues zu Compilers

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.