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

Aperta
#20,892 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Ambito
compilers

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
F#
Stelle
4.3k
Fork
883
Merge medio
3g 13h
PR unite (30g)
108

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di dotnet/fsharp

Tutte le issue di dotnet/fsharp

Issue simili

Altre issue su Compilers

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.