add FS-1331 - Allow opens in type and expression scopes#810
add FS-1331 - Allow opens in type and expression scopes#810ijklam wants to merge 7 commits intofsharp:mainfrom
Conversation
| ```fsharp | ||
| type C() = | ||
| do printfn "%d" Int32.MaxValue // <- Cannot find the `Int32` here | ||
| open System |
There was a problem hiding this comment.
Shouldn't this be considered an expressions-scoped open and NOT be valid in the member?
There was a problem hiding this comment.
The original suggestion doesn't mentioned this, but I think the contents opened in type should be valid in members.
There was a problem hiding this comment.
Yes, that makes sense. I was somehow thinking of an open inside the do body. Good that you added the extra example above for it.
| This feature is only available in implementation files. | ||
|
|
||
| ```fsharp | ||
| type C() = |
There was a problem hiding this comment.
Can we please add some samples about ?
type IFace =
abstract F : int -> int
open System
member _.F _ = 3
{ new IFace with
open System
member _.F _ = 3
}
type C () =
member _.F () = 3
open System
member _.F _ = 3
open System
interface IFace with
open System
member _.F _ = 3
type A =
| A
open System
member _.F _ = 3
and B =
| B
open System
member _.F _ = 3
type U =
| A
| B
open System
member _.F _ = 3
type R =
open System
{ A : int }
open System
member _.F _ = 3There was a problem hiding this comment.
opens in types can only be on the beginning of the type definition due to the complexity of making it can applied to member/val/interface ... with following the up-to-down order.
Object expressions and interface ... with cannot contain opens.
There was a problem hiding this comment.
I'd be fine with the feature shipping, with none of the places @edgarfgp showcased, being supported; and giving more room for consideration about the samples and in-type-definition semantics.
Ideally, it could be used in a do block at type level, let bindings, and in members themselves (under the member implemention block, not in between in stuff like properties).
|
It looks like Edit: actually it is present in the examples. Still, I think a mention in the text would be welcome. |
|
Can a section "Changes to the F# spec" be added? |
|
That makes sense. I will re-review once spec changes are added. |
Click “Files changed” → “⋯” → “View file” for the rendered RFC.