fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

[WIP] RFC-1331 Expression-scoped opens

Open ijklam opened this issue 4 months ago • 5 comments

Description

Implements fsharp/fslang-suggestions#96 RFC fsharp/fslang-design#810

This PR only implements open in expressions. Open in type is not implemented.

图片

Checklist

  • [x] Test cases added
  • [x] Release notes entry updated:
  • [x] Add language feature flag

ijklam avatar Aug 04 '25 07:08 ijklam

:heavy_exclamation_mark: Release notes required


:white_check_mark: Found changes and release notes in following paths:

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/10.0.100.md
LanguageFeatures.fsi docs/release-notes/.Language/preview.md

github-actions[bot] avatar Aug 04 '25 07:08 github-actions[bot]

This PR does not implement "open in types" feature. It needs some refactoring to implement the feature, which needs someone who knows a lot about the typechecking mechanics. I did make a prototype, but I am not satisfied on its restriction, working way and performance. It requires putting open declarations on the beginning of a type definition, and has bug in type ... and ... declaration. While typechecking, it need find and apply open declarations to the environment multiple times, and it causes the UnusedOpens.getUnusedOpens returning duplicated items for type-scoped opens. Also, when the line of open has error, it will raise multiple same error for it.

ijklam avatar Aug 08 '25 10:08 ijklam

@ijklam : Thanks for the summary of the current state. I will convert the PR to a draft to prevent accidental merge for now.

T-Gro avatar Aug 11 '25 12:08 T-Gro

@ijklam : I thought about the remaining obstacles.

I think the 'open in expression' on its own would be a good addition and I believe scoping the feature between expressions and types could work. 'open in type' would then be a second part of the RFC, waiting to be implemented (by anyone brave enough to tackle it).

T-Gro avatar Aug 26 '25 13:08 T-Gro

'open in type' would then be a second part of the RFC, waiting to be implemented (by anyone brave enough to tackle it).

Actually the syntax node of "open in type"(SynMemberDefn.Open) exists from long time ago but no one implements the feature. Maybe it is too difficult 😄.

ijklam avatar Sep 04 '25 09:09 ijklam