Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Chiusa
#9,038 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@cknitt ci sta già lavorando.

Dal 25/10/2026.

  • #9039 di @cknitt — chiusa senza merge
  • #9040 di @cknitt — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
ocaml
Ambito
compilers

Direzione di ricerca

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.

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

Descrizione

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).

Lingua principale
OCaml
Stelle
7.5k
Fork
483
Merge medio
20h
PR unite (30g)
219

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

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 rescript-lang/rescript

Tutte le issue di rescript-lang/rescript

Issue simili

Altre issue su Compilers

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.