Completion offers nothing for an array element after a spread

Đang mở
#9,183 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
55/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ệ
ocaml
Lĩnh vực
devtools

Hướng nghiên cứu

The bug is in traverse_expr in analysis/src/completion_expressions.ml, which handles Pexp_array and dict literals but has no case for the Pexp_spread node. Start by reading the Pexp_array branch to see how element positions are traversed, then add handling so an array spread keeps the expected element type. Done when completion after [...base, ] offers First and Second, matching [First, ], and the untyped File module fallback no longer appears.

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

Mô tả

Found by differential semantic drift analysis from b123b7c3 to c10223e8.

What is broken

type kind = First | Second
let base: array<kind> = [First]
let ys: array<kind> = [First, ]
//                            ^com First, Second
let ys2: array<kind> = [...base, ]
//                               ^com nothing

At c10223e8, completion at the second position returns no items; at b123b7c3 it returned a single bogus [] item of type 'a (from Primitive_array.spread). [...base, Fi] falls back to untyped completion (offering First and the module File). The expected items are the same as for [First, ].

traverse_expr handles Pexp_array and dict literals, including dict spreads, but has no case for the Pexp_spread node that #8905 introduced for array and list literals with spreads.

Possible cause (speculation only)

Before #8905 a spread literal was a call to Primitive_array.spread, which completion treated as a function argument; the new node falls into the default case.

🤖 Generated with Claude Code

Ngôn ngữ chính
OCaml
Star
7.5k
Fork
484
Merge trung bình
17 giờ 2 phút
Pull request đã merge (30 ngày)
249

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ề DevTools

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.