Integer range patterns ending at 2147483647 generate incorrect JavaScript
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 70/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, ocaml
- Área
- compilers
Línea de trabajo
Use the maintenance/12.x compiler with the supplied ReScript switch, first inspecting the generated JavaScript for the integer-range condition. Reproduce the boundary cases and compare the compiler's handling of the exclusive upper bound with the signed 32-bit limit. Done means the generated check accepts 2147483645–2147483647 and rejects 2147483644, including the other listed switch shapes.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
An integer or-pattern ending at 2147483647 (the maximum signed 32-bit integer) compiles to an impossible bound check and rejects values that should match.
Reproduced with the ReScript 12.3.1 compiler on macOS arm64, using the maintenance/12.x code both before and after the change in #8714.
type response = {status: int}
let inRange = (x: response) =>
switch x {
| {status: 2147483645 | 2147483646 | 2147483647} => true
| _ => false
}
Generated JavaScript, identical before and after #8714:
function inRange(x) {
let match = x.status;
if (match >= 2147483645) {
return match < -2147483648;
} else {
return false;
}
}
Expected and observed results:
| Input status | Expected | Actual |
|---|---|---|
| 2147483644 | false | false |
| 2147483645 | true | false |
| 2147483646 | true | false |
| 2147483647 | true | false |
The generated condition requires the same integer to be at least 2147483645 and less than -2147483648, so it can never succeed. This appears to be overflow when converting the exclusive upper bound 2147483647 + 1 into a 32-bit integer literal.
The same failure also reproduces with a plain integer switch, nested records, tuples, variant payloads, arrays, and switches on function-call results.
This was found while reviewing #8714 and is a separate, pre-existing bug: the unsigned-range fix in that PR neither introduces nor fixes it.
- Lenguaje dominante
- OCaml
- Estrellas
- 7.5k
- Forks
- 485
- Merge medio
- 1 d 34 min
- PR fusionados (30 d)
- 52
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
- Sin 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 5/5 Más de una semana Aptitud para principiantes 35/100
rescript-lang/rescript#8727 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
rescript-lang/rescript#8726 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 76/100
rescript-lang/rescript#8713 ·
Los mantenedores suelen responder en 1 día
-
A regex literal that starts a statement is parsed as division, and the formatter removes the parentheses that prevent itPosiblemente ocupada @fhammerschmidt la tomó hace 4 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 68/100
rescript-lang/rescript#8688 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
bsc crashes with `Fatal error: exception Not_found` on `Some(x)` when the type of `x` comes from a transitive dependencyPosiblemente ocupada @fhammerschmidt la tomó hace 4 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 76/100
rescript-lang/rescript#8687 ·
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
microsoft/TypeScript#64661 ·
Los mantenedores suelen responder en 1 día
-
good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Sim20004/teapot-lang#248 ·