-
Notifications
You must be signed in to change notification settings - Fork 825
[WIP] RFC-TBD Ease restrictions on static members and let in union and records #14132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@vzarytovskii will be this inserted in VS and sdk for 17.5 ? |
Hi @dsyme , would you mind if I attempt to revive this, learn something new and continue where you ended + cover it with tests? Or are you planning to continue yourself? |
@T-Gro Please do! I'll review and leave further notes |
I think my only concerns were about initialization for union types, but I'll take a look and write notes for testing too |
/run fantomas |
Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com>
Ran fantomas: https://github.com/dotnet/fsharp/actions/runs/5210064817 |
@dsyme I revived the branch and continued here. |
@T-Gro This is great!
The slight concern is that for union types we emit Context:
I think covering a range of common cases of static init will be enough. Check particularly the singleton cases, e.g.
Here accessing T.X from another file should obv trigger. I guess the important thing here is that initialization of the file content needs to access initialization of the static content of T (but not vice-versa) With variations
On a quick glance I think I've seen these in the tests and it all looks ok tbh |
Thanks @dsyme for the insight. I know do remember that from the IlxGen file-level init code, and is actually something I have missed in the tests - I should have at least some scenario for multi-file test cases, of static init not being in the final file. (because IlxGen has different logic for the very last file) (i.e. an action in main triggering static init of another file later, not immediately) ==> I will add those ( I will reuse some of the existing test code I already wrote, but just call it from another file added to the compilation) |
I have now covered the multi-file scenario as well: It does work as expected:
|
@T-Gro feel free to close if everything is covered in your PR. |
This is the beginning of fsharp/fslang-suggestions#1182
Basically, allow static members and let in a wider range of type definitions