[WIP] RFC-1331 Expression-scoped opens
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
:heavy_exclamation_mark: Release notes required
:white_check_mark: Found changes and release notes in following paths:
Change path Release notes path Description src/Compilerdocs/release-notes/.FSharp.Compiler.Service/10.0.100.md LanguageFeatures.fsidocs/release-notes/.Language/preview.md
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 : Thanks for the summary of the current state. I will convert the PR to a draft to prevent accidental merge for now.
@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).
'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 😄.