-
Notifications
You must be signed in to change notification settings - Fork 834
Remove ML compatibility #19143
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
base: main
Are you sure you want to change the base?
Remove ML compatibility #19143
Conversation
❗ Release notes required
|
auduchinok
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this @kerams!
What do you think about keeping the parser rules and just always producing the errors? We could easily remove them in future if wanted to repurpose these constructs in the language. For now keeping them would allow to parse older code which could be nice as long as it doesn't need maintenance in the parser.
| | LPAREN appTypePrefixArguments rparen appTypeConPower | ||
| { let args, commas = $2 | ||
| if parseState.LexBuffer.SupportsFeature LanguageFeature.MLCompatRevisions then | ||
| mlCompatError (FSComp.SR.mlCompatMultiPrefixTyparsNoLongerSupported()) (unionRanges (rhs parseState 1) $4.Range) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just always produce this error instead of removing the parser rule and failing to parse a possibly old file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The compiler will already error on seeing a deprecated language version value, prior to starting parsing.
That's been the case since ML compatibility was deprecated. The only way to get rid of it was the combination of the 2 flags. We could keep the parser rules, but one of the benefits of doing this was a slight parser/lexer simplication, and I'm not sure what would be the practical benefit of preserving them. |
I think keeping the simple rules that don't require any additional support (like the type arguments in parens) would be beneficial. I see it as a sort-of error recovery rules. |
|
Yes, long term code simplification should be the motivator here, since the rules were there but obsolete for many years. (and it is always possible to e.g. copy existing parser rules+code and build a dedicated "ML-style-syntax-tree nuget" with it.) |
This comment was marked as outdated.
This comment was marked as outdated.
Is it because of the changes this PR did? |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
The first error is legit - the error message is build up by the parsing state machine by the tokens which are allowed next. The second indicates a failed optimization, are you running -c Release and release versions of all things? |
|
Yeah, debug... Thanks to you both. By the way, would it be possible to update the required SDK to 10.0.1 in main? I do have rc2 installed, but VS really doesn't like it so I have to edit global.json. |
|
Yep, sure. Done at #19149. |
|
This is pretty much ready.
I could do that here, but there are a bunch of tests targeting lower than 8, so the PR would become even messier than it already is. Regarding release notes, should they really go in the files suggested in the first comment? |
Yes, this is correct. Compiler service API has changed, library has changed and language has changed as well.
I am open for ideas on how to enable it for tests temporarily and postpone cleanup - a lot of tests can be plain deleted because they will be no longer testing a relevant setup. However, some were using langVersion for convenience, but still test relevant things - I see how this could end up increasing the diff a lot. We should have a user-friendly warning and optimize for the F# code maintainer not aware of what is happening here or over at fslang-suggestions. From their perspective, a new update to VS can just "randomly break unrelated code files" and we can prevent a lot of confusion if there is a direct message saying "langVersion xyz is out of support in F#X, please download Y". A |
|
Added. I just throw on <8, there's no SDK <-> language version matrix. An exercise for someone else down the line;) I know it would be more accurate to say that features in version %s have become part of core F# and are always enabled, but that specifically doesn't apply to ML compatibility. Feel free to change it however you see fit. |
|
The wording is good, thanks for adding that 👍 . I am also thinking about building an unsupported (= not officially shipped) .vsix right before this change and uploading it to people in case they need to maintain such an unsupported codebase. But I can do that JIT when/if the request comes at all. (reasoning is that pre-change tooling will be better in migrating the codebase, since it will give more accurate warnings) |
Changing in order to align with dotnet/fsharp#19143
T-Gro
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This contribution simplifies the compiler codebase, especially the lexer and parser.
Big thank you to @kerams for starting the activity of stabilizing the "core of F# language" by reducing the number of supported versions, and taking the largest language feature by far!
I added a few minor comments only.
| | LPAREN appTypePrefixArguments rparen appTypeConPower | ||
| { let args, commas = $2 | ||
| if parseState.LexBuffer.SupportsFeature LanguageFeature.MLCompatRevisions then | ||
| mlCompatError (FSComp.SR.mlCompatMultiPrefixTyparsNoLongerSupported()) (unionRanges (rhs parseState 1) $4.Range) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The compiler will already error on seeing a deprecated language version value, prior to starting parsing.
| /* Like appType but gives a deprecation error when a non-atomic type is used */ | ||
| /* Also, doesn't start with '{|' */ | ||
| atomTypeNonAtomicDeprecated: | ||
| | LPAREN appTypePrefixArguments rparen appTypeConPower |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the atomTypeNonAtomicDeprecated be fully removed (incl. this file's header) and inlined with atomType?
| // Output Raw Parser Spec AST | ||
|
|
||
| let StringOfSym sym = match sym with Terminal s -> "'" ^ s ^ "'" | NonTerminal s -> s | ||
| let StringOfSym sym = match sym with Terminal s -> String.Concat("'", s, "'") | NonTerminal s -> s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please do a final "62" full text search?
This file and the fslex files still have it, among others.
I have also not seen a removal of the message behind "62", which I found strange.. ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was removed
fsharp/src/Compiler/Facilities/DiagnosticsLogger.fs
Lines 613 to 617 in 0b836fb
| let mlCompatWarning s m = | |
| warning (UserCompilerMessage(FSComp.SR.mlCompatMessage s, 62, m)) | |
| let mlCompatError s m = | |
| errorR (UserCompilerMessage(FSComp.SR.mlCompatError s, 62, m)) |
including fscomp texts
| * `SynExprLetOrUseTrivia` is now `SynLetOrUseTrivia`. ([PR #19090](https://github.com/dotnet/fsharp/pull/19090)) | ||
| * `SynMemberDefn.LetBindings` has trivia. ([PR #19090](https://github.com/dotnet/fsharp/pull/19090)) | ||
| * `SynModuleDecl.Let` has trivia. ([PR #19090](https://github.com/dotnet/fsharp/pull/19090)) | ||
| * Removed support for `.ml` and `.mli` source files. ([PR #19143](https://github.com/dotnet/fsharp/pull/19143)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change deserves a lift in Versions.props for the <FCS.. version, FCS consumers will need to accommodate.
(does not belong to this file, but tooling is failing me horribly on this PR. I lost all comments already :(( )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will these changes also automatically flow to some minor update for .NET 10? That would make the current out of support error message misleading. (which is why I asked whether the changelog belongs in the 10.0.200 markdown files and not vnext)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of now it would still go to the 10.0.200 release (early next year) unless we wait a little and make it skip that and go into the first preview of net11 instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But no matter which of the two it is (10.0.200 or a v11 early preview), 10.0.10x SDK band will not get this. 10.0.10x will remain the LTS supported version with capability for compiling code with ML syntax.
Description
Implements fsharp/fslang-suggestions#1407
asr,land,lor,lsl,lsr,lxor(modcontinues to be reserved)orand&operators in FSharp.Core for binary compatibility.mland.mlisource files#lightand#indentdirectives (they are now a no-op, combined with"off"they give an error)--light,--indentation-syntax,--no-indendation-syntax,--ml-keywordsand--mlcompatibilitycompiler/fsi flags#lightfrom source code. There are hundreds of these files, but they can be safely skipped during reviewChecklist
Test cases added
Performance benchmarks added in case of performance changes
Release notes entry updated: