Switch on an option of an untagged variant with an `@as(undefined)` case takes the wrong arm for `Some` of that case
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 28/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Ativa
- Stack de tecnologia
- javascript, ocaml
- Domínio
- compilers
Direção de pesquisa
Start with rejects_nested_some in compiler/ml/matching.ml, which decides whether a pattern reads the payload with Pval_from_option_not_nest and skips unwrapping the nested Some box. Reproduce with the g(Some(U)) snippet from the issue and inspect the compiled JavaScript for the typeof and === undefined tests. Done when Some(U) reaches the Some(_) arm and prints SU, with the constant and runtime-built cases agreeing.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Found by differential semantic drift analysis from b123b7c3 to c10223e8.
What is broken
@unboxed type t = @as(undefined) U | S(string) | I(int)
let g = (x: option<t>) =>
switch x {
| None => "None"
| Some(S(_)) => "SS"
| Some(I(_)) => "SI"
| Some(_) => "SU"
}
Console.log(g(Some(U)))
Expected SU. At c10223e8 it prints SI; at b123b7c3 it printed None (the construction bug fixed by #9008). A Some(U) built at run time (let h = v => g(Some(v)), h(U)) prints SI at both commits, so the match bug predates the range; #9008 makes constant values reach it too. Matches that name Some(U) explicitly, and tagged variants, are correct.
The compiled g tests x !== undefined, then x === undefined, then typeof x === "string", and otherwise returns "SI", without unwrapping the nested-Some box first: the boxed Some(U) fails the first two tests and lands in the last case.
rejects_nested_some returns true for _ and for untagged payload patterns, so the match reads the payload with Pval_from_option_not_nest, which skips unwrapping.
Possible cause (speculation only)
rejects_nested_some assumes that each pattern rejects the box on its own test, but the untagged dispatch decides the last remaining case by elimination, without a test of its own.
🤖 Generated with Claude Code
- Linguagem predominante
- OCaml
- Estrelas
- 7.5k
- Forks
- 484
- Merge médio
- 17h 2min
- PRs com merge (30d)
- 249
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de rescript-lang/rescript
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
rescript-lang/rescript#9182 ·
Mantenedores costumam responder em até 1 dia
-
Issues from differential semantic drift analysis (b123b7c3 to c10223e8)Talvez já em andamento @cknitt assumiu hoje. Aberta
rescript-lang/rescript#9186 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 38/100
rescript-lang/rescript#9185 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 55/100
rescript-lang/rescript#9183 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
rescript-lang/rescript#9181 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de rescript-lang/rescript
Issues semelhantes
-
arrays asr pass bug ICE intrinsic medium priority
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
rubys/roundhouse#1757 ·
-
Function arguments are bound one at a time, so later arguments see already-rebound parametersAbertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
5250ng/5250script#19 ·
-
bug community
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 77/100
tenstorrent/tt-mlir#9396 ·