dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.87k stars 779 forks source link

can't AutoOpen namespace-qualified modules #13141

Closed jcmrva closed 2 years ago

jcmrva commented 2 years ago

The AutoOpen attribute appears to be ignored on top-level modules that include a qualified namespace.

Repro steps

Utils.fs


[<AutoOpen>]
module Example.Utils

let tee fn v = fn v v

> Library.fs

module Say

let hello name = name |> tee (printfn "Hello %s") // err |> ignore



**Expected behavior**

Compiles.

**Actual behavior**

FS0039 compile error `The value or constructor 'tee' is not defined.`

**Known workarounds**

- Explicitly open the module.
- Fully qualify module members.
- Don't use qualified-namespaces.

**Related information**

* OS: Win10
* .NET 6 and .NET 7 (7.0.100-preview.4.22252.9)
* Ionide and .NET CLI
auduchinok commented 2 years ago

@jcmrva The attribute is only applied to the module itself, not to the containing namespace. The language spec says that this attribute will open Utils module automatically when a Example namespace is opened.

dsyme commented 2 years ago

@auduchinok Thanks, yes, this is correct - this is by design