Integer range patterns on record fields match values below the range
維護者通常 1 天內回覆
已經有一個關聯 PR 被合併了。
- #8714 來自 @mvaled —— 已合併
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 76/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- javascript, ocaml
- 領域
- compilers
研究方向
Start in Js_exp_make.is_out and compare its fallback handling with commit 6d78c5832781165685b45bb2092d8edf170b75ae, where to_uint32 was removed. Reproduce the record-field range example and inspect the generated JavaScript. Done means values below 502 no longer match the 502–504 range while the valid range still does.
由索引模型根據 Issue 內容生成。
描述
Reported in the forum: https://forum.rescript-lang.org/t/potential-bug-in-code-generation-of-subpattern-of-integers-httperror-status-502-503-504-rescript-12-and-13/7598
Matching a contiguous range of integers on a value that is not a plain variable (e.g. a record field) generates a signed comparison, so every value below the range also matches.
type response = {status: int}
let isRetriable = error =>
switch error {
| {status: 502 | 503 | 504} => true
| _ => false
}
ReScript 12 and 13 (alpha) generate:
function isRetriable(error) {
return (error.status - 502 | 0) <= 2;
}
which returns true for 404, 500, 501, etc. ReScript 10 and 11 generated (error.status - 502 >>> 0) <= 2, which is correct.
A bare switch x { | 502 | 503 | 504 => ... } is not affected; it compiles to !(x > 504 || x < 502).
The unsigned conversion in the fallback case of Js_exp_make.is_out was lost in https://github.com/rescript-lang/rescript/commit/6d78c5832781165685b45bb2092d8edf170b75ae when to_uint32 was removed.
- 主要語言
- ReScript
- 星號
- 7.5k
- 分支
- 483
- 平均合併
- 1 天 3 小時
- 30 天內合併 PR
- 136
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
rescript-lang/rescript 的其他 Issue
-
難度 5/5 一週以上 新手友好度 25/100
rescript-lang/rescript#8878 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 35/100
rescript-lang/rescript#8806 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 35/100
rescript-lang/rescript#8798 ·
維護者通常 1 天內回覆
-
難度 3/5 半天 新手友好度 58/100
rescript-lang/rescript#8757 ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 40/100
rescript-lang/rescript#8753 ·
維護者通常 1 天內回覆
查看 rescript-lang/rescript 的全部 Issue
相似的 Issue
-
bug priority: P2
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
crash lld:MachO
難度 2/5 1-3 小時 新手友好度 62/100
llvm/llvm-project#233265 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 88/100
snowballstem/snowball#311 ·
-
難度 2/5 1-3 小時 新手友好度 78/100
JakeChampion/lang#12684 ·
維護者通常 1 天內回覆
-
`lvm_compact` has no self-hosted twin, and `docs/158` §5 says every language-face component must未關閉bug sev-3 vm
難度 2/5 1-3 小時 新手友好度 65/100