Coercion hint suggests the inner type when the mismatch is nested
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 75/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- ocaml
- Domínio
- compilers
Direção de pesquisa
A correção está em compiler/ml/error_message_utils.ml: localize onde a dica de coercion é construída a partir de target_type e mude-a para usar top_level_types. Compile o snippet ReScript da issue para reproduzir a dica incorreta. Feito quando a coercion sugerida é (make :> unit => iterable<int>) e o exemplo compila.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
When a type mismatch is nested inside another type, the "compatible at runtime" hint suggests a coercion to the inner type instead of the whole expected type, and the suggested code doesn't compile.
let consume = (_f: unit => Iterable.t<int>) => ()
let make: unit => Generator.t<int, unit, unit> = %raw(`function* () { yield 1 }`)
let () = consume(make)
This has type: unit => Generator.t<int, unit, unit>
But this function argument is expecting: unit => Iterable.t<int>
The incompatible parts:
Generator.t<int, unit, unit> (defined as Generator.t<int, unit, unit>) vs
Iterable.t<int> (defined as iterable<int>)
Possible solutions:
- These types are compatible at runtime. You can use the coercion operator to convert to the expected type: (make :> iterable<int>)
Applying the suggestion fails with Type unit => Generator.t<int, unit, unit> is not a subtype of iterable<int>. The right suggestion is (make :> unit => iterable<int>), which compiles.
Cause
In compiler/ml/error_message_utils.ml, the hint checks Ctype.subtype on the top-level types of the trace (top_level_types, "Coercion should always target the top level types"), but builds the rewrite from target_type, which is the inner incompatible pair. Printing the top-level expected type instead should fix it.
(The doubled Generator.t<…> (defined as Generator.t<…>) in the same output is #8997.)
- Linguagem predominante
- OCaml
- Estrelas
- 7.5k
- Forks
- 483
- Merge médio
- 19h 35min
- PRs com merge (30d)
- 208
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
-
Per-constructor @unboxed is not compared across interfaces or coercionsTalvez já em andamento @cknitt assumiu hoje. Aberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 25/100
rescript-lang/rescript#9038 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
rescript-lang/rescript#9006 · 1 reação ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 70/100
rescript-lang/rescript#8997 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 68/100
rescript-lang/rescript#8994 ·
Mantenedores costumam responder em até 1 dia
-
@notUndefined in an interface is not checked against the implementationTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
rescript-lang/rescript#8964 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de rescript-lang/rescript
Issues semelhantes
-
area:codegen backend:cuda backend:hip bug direction:input
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
CrossGL/crosstl#3061 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
-
build
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
AOMediaCodec/SVT-AV1#2500 ·
-
SIGSEGV in symex on __builtin_constant_p of a void expressionTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Abertabug goto-symex
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 83/100
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 85/100
leanprover/lean4#15925 ·
Mantenedores costumam responder em até 1 dia