Completion inside a list literal ignores the element type

Đang mở
#9,212 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ó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá 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

Start by comparing the completion context path for array literals with the Type_utils.extract_type behavior described for list<'a>. The issue names no test file, and notes there are no existing completion tests for list literals, so first locate the completion tests and add coverage for typed list elements, including partially typed elements and an empty list. Done means completions use the list element type as they do for arrays.

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

Mô tả

What is broken

Completion inside a list{…} literal doesn't use the list's element type, while the same position in an array literal does:

type kind = First | Second

let arr: array<kind> = [First, ]
//                            ^com First, Second
let ys: list<kind> = list{First, }
//                              ^com nothing
let zs: list<kind> = list{First, Se}
//                                 ^com only `module Set`
let f = (x: list<kind>) => x
let _ = f(list{})
//             ^com nothing

The completion log shows why: for the array the context path is array<Type[kind]> and then Type[kind], but for the list it is Type[list], so the element type kind is lost. A partly typed element then falls back to untyped completion (module Set for Se).

Checked on master ac7357822e. There are no completion tests for list literals, which is why it went unnoticed. It came up while fixing array spreads in #9199 (#9183), which leaves lists alone for this reason.

Possible cause (speculation only)

Type_utils.extract_type has no case for list<'a>, and looking up the built-in list type fails, so there is no element type to complete from.

A related limit: list{...xs, } with a trailing hole is parsed as the plain expression xs, because a spread in tail position is a :: chain, so no completion position remains there.

🤖 Generated with Claude Code

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

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.