Internal type in the global namespace of a referenced assembly shadows other referenced public members

Đang mở
#20,892 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 3 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
45/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Lĩnh vực
compilers

Hướng nghiên cứu

Start by running the provided F# repro with and without the referenced assembly, then trace compiler name resolution for unqualified expression identifiers and inaccessible types from referenced assemblies. Done means the unqualified id resolves to Operators.id and the repro prints [1; 3] with the assembly referenced.

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

Mô tả

Bug Needs-Triage

When a referenced assembly contains an internal top-level type named id in the global namespace, an unqualified id in my code no longer resolves to Operators.id. It resolves to the inaccessible type instead.

Repro:
#r "nuget: c1.win.input,10.0.20262.832" // just to pull the package
#r @"%USERPROFILE%\.nuget\packages\c1.win.input\10.0.20262.832\lib\net10.0-windows7.0\C1.Win.Input.10.dll" // change %USERPROFILE% to the actual path 

let xs = [ Some 1; None; Some 3 ] |> Seq.choose id |> Seq.toList
printfn "%A" xs
Actual:

error FS0001: This expression was expected to have type 'int option' but here has type 'unit'

In a project build, the same code gives error FS0801: This type has no accessible object constructors.

Expected:

[1; 3]

Without the assembly being referenced, the script prints [1; 3].

An inaccessible type from another assembly shouldn’t take part in name resolution for an ordinary expression identifier.

Workaround:

Use qualified names.

Ngôn ngữ chính
F#
Star
4.3k
Fork
883
Merge trung bình
3 ngày 13 giờ
Pull request đã merge (30 ngày)
108

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 dotnet/fsharp

Tất cả issue của dotnet/fsharp

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.