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

Per-constructor @unboxed is not compared across interfaces or coercions

Offen
#9,038 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@cknitt arbeitet bereits daran.

Seit 25.10.2026.

  • #9039 von @cknitt — ohne Merge geschlossen
  • #9040 von @cknitt — offen

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
25/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
ocaml
Bereich
compilers

Rechercherichtung

The cause lies in Includecore.compare_variants, Variant_coercion.variant_representation_matches, and Printtyp.print_variant_configuration_issue in the compiler. Read those modules to see how variant tags and @unboxed are checked. Done means an untagged constructor only matches an untagged one across interfaces and coercions, with correct error naming.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Whether a constructor is @unboxed (untagged) is not compared across interfaces or in coercions:

module M: {
  type t = | @unboxed A(int) | B({x: int})
  let a: t
} = {
  type t = | A(int) | B({x: int})
  let a = A(3)
}
let n = switch M.a { | A(i) => i | B(_) => -1 }   // -1: the client expects 3, the implementation built {TAG: "A", _0: 3}

The reverse direction is accepted too. So is a coercion between the two representations:

type a = | @unboxed A(int) | B({x: int})
type b = | A(int) | B({x: int}) | C
let x: b = (A(3): a :> b)   // 3 is not a b: matching it gives C

Also, when the @unboxed configurations of two variants differ, the coercion error says the wrong variant is unboxed ("Variant c is unboxed" for the plain one).

Observed on master (d48d577bf6). Cause:

  • Includecore.compare_variants compares tags of tagged constructors only, so a tagged and an untagged constructor agree.
  • The coercion check compares only the declared @as (Variant_coercion.variant_representation_matches).
  • Printtyp.print_variant_configuration_issue inverts "not".

Expected: an untagged constructor agrees only with an untagged one, in interfaces and coercions alike, and the error names the unboxed variant.

Found by a review of the untagged variant work (#8950).

Vorherrschende Sprache
OCaml
Sterne
7.5k
Forks
483
Ø Merge
19 Std. 35 Min.
Gemergte PRs (30 T.)
208

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.