Untagged variant with Blob and File cases never matches File when Blob is declared first
Los mantenedores suelen responder en 1 día
@cknitt ya está trabajando en esto.
Desde el 21/10/2026.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- javascript
- Área
- compilers
Línea de trabajo
Start with compiler/ml/ast_untagged_variants.ml, especially type_to_instanceof_backed_obj, and trace how untagged variant cases become ordered instanceof checks. Check the compiler tests for untagged variants and add coverage for File and Blob in both declaration orders. Done means the subclass case is matched first regardless of order, or the unsupported variant is rejected.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
An untagged variant with cases for a class and one of its subclasses tests them in declaration order, so the subclass case can never match when it is declared second:
@unboxed
type upload = Blob(Blob.t) | File(File.t)
let describe = u =>
switch u {
| Blob(_) => "blob"
| File(_) => "file"
}
compiles to
function describe(u) {
if (u instanceof Blob) {
return "blob";
} else {
return "file";
}
}
File extends Blob, so for File(new File(["x"], "a.txt")) the check u instanceof Blob is true and describe returns "blob" (checked in Node). Declaring File(File.t) | Blob(Blob.t) instead emits u instanceof File and works, whatever the order of the switch cases.
Expected: a subclass is tested before its superclass regardless of declaration order, or the variant is rejected.
Cause: type_to_instanceof_backed_obj in compiler/ml/ast_untagged_variants.ml maps a fixed list of stdlib type names to classes but records no relation between them, so the tests are emitted in declaration order. File/Blob is the only subclass pair in that list today. The same question comes up for user-declared classes (e.g. HTMLElement extends Element) if bindings can declare their runtime class.
Reproduced on current master.
- Lenguaje dominante
- OCaml
- Estrellas
- 7.5k
- Forks
- 483
- Merge medio
- 20 h
- PR fusionados (30 d)
- 219
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de rescript-lang/rescript
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
rescript-lang/rescript#9037 ·
Los mantenedores suelen responder en 1 día
-
RFC: Temporal API bindingsAbierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 12/100
rescript-lang/rescript#9044 · 2 reacciones ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
rescript-lang/rescript#9006 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 70/100
rescript-lang/rescript#8997 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
rescript-lang/rescript#8994 ·
Los mantenedores suelen responder en 1 día
Todos los issues de rescript-lang/rescript
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Recover inside a parameter listAbiertoenhancement scope:diagnostics scope:syntax
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
-
code: refactoring good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
idris-lang/Idris2#3887 ·
Los mantenedores suelen responder en 1 día
-
luaebpf: a write to a field of a table the body built is refused as an assignment to a globalAbiertoseverity: low
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
luainkernel/lunatik#2207 ·
Los mantenedores suelen responder en 1 día
-
backend:X86 generated by fuzzer llvm:globalisel miscompilation
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
llvm/llvm-project#235468 · 1 comentario ·
Los mantenedores suelen responder en 1 día