Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Integer range patterns on record fields match values below the range

Đang mở
#8,713 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
76/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, ocaml
Lĩnh vực
compilers

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
OCaml
Star
7.5k
Fork
485
Merge trung bình
1 ngày 2 giờ
Pull request đã merge (30 ngày)
62

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của rescript-lang/rescript

Tất cả issue của rescript-lang/rescript

Issue tương tự

Thêm issue về Compilers

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.