Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Cerrado
#9,038 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@cknitt ya está trabajando en esto.

Desde el 25/10/2026.

  • #9039 de @cknitt — cerrado sin fusionar
  • #9040 de @cknitt — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
ocaml
Área
compilers

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
OCaml
Estrellas
7.5k
Forks
483
Merge medio
20 h
PR fusionados (30 d)
219

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de rescript-lang/rescript

Todos los issues de rescript-lang/rescript

Issues similares

Más issues de Compilers

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.