Integer range patterns ending at 2147483647 generate incorrect JavaScript
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 70/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- javascript, ocaml
- Domaine
- compilers
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- OCaml
- Étoiles
- 7.5k
- Forks
- 485
- Merge moyen
- 1 j 34 min
- PR mergées (30 j)
- 52
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de rescript-lang/rescript
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
rescript-lang/rescript#8727 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
rescript-lang/rescript#8726 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 3/5 1-2 jours Accessibilité débutants 76/100
rescript-lang/rescript#8713 ·
Les mainteneurs répondent en général sous 1 jour
-
A regex literal that starts a statement is parsed as division, and the formatter removes the parentheses that prevent itPeut-être pris @fhammerschmidt l’a pris il y a 3 jours. Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 68/100
rescript-lang/rescript#8688 · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
bsc crashes with `Fatal error: exception Not_found` on `Some(x)` when the type of `x` comes from a transitive dependencyPeut-être pris @fhammerschmidt l’a pris il y a 3 jours. Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 76/100
rescript-lang/rescript#8687 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de rescript-lang/rescript
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
cc65/cc65#3000 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
I-prioritize needs-triage regression-from-stable-to-beta T-lang
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
rust-lang/rust#163830 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Swift route tables omit digit constraints from generated main and testsPeut-être pris @dchuk l’a pris il y a 1 jour. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
rubys/roundhouse#444 ·
Les mainteneurs répondent en général sous 1 jour
-
IntrinsicLowering::LowerCTPOP runs into assertion with LLVM 23Peut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouvertecrash llvm:codegen
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
llvm/llvm-project#229064 ·
Les mainteneurs répondent en général sous 1 jour
-
area:lowering kind:bug
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour