Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Fechada
#9,038 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@cknitt já está trabalhando nisso.

Desde 25/10/2026.

  • #9039 de @cknitt — fechado sem integrar
  • #9040 de @cknitt — aberto

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
25/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
ocaml
Domínio
compilers

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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

Linguagem predominante
OCaml
Estrelas
7.5k
Forks
483
Merge médio
20h
PRs com merge (30d)
219

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de rescript-lang/rescript

Todas as issues de rescript-lang/rescript

Issues semelhantes

Mais issues de Compilers

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.