-
Notifications
You must be signed in to change notification settings - Fork 802
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
Separator between member and type annotation interpreted as operator #15923
Separator between member and type annotation interpreted as operator #15923
Conversation
@vzarytovskii Would it be acceptable to allow now |
Not sure, it's been deliberately deprecated, probably for a reason? |
From what I can see, the error might be there to potentially allow Is that in the F# team plans? The error recovery and reporting for this scenario are currently bad |
We don't have plans to use it, @dsyme might have some insight on why is it disallowed. |
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 to the token processing seems to be good from a glance, but I think that we should not enable new operators unless there's an approved language suggestion.
Thanks for the review. I went through the lex.fsl rules and noticed that we are doing the same for, ie This change will make But if you have a better way of dealing with this specific issue, any suggestion is welcome :) |
We can produce an error about this operator during type checking. |
99200f1
to
8184817
Compare
@edgarfgp This looks like a nice fix. It's so good to remove these glitches. Regarding |
By removing the check in for module >: = ...
module `>:` = ...
type >: = ...
So I would love to get some feedback in the following questions:
|
Since there are no plans for using it by F# itself, I do not see a reason for not allowing this as a custom operator. |
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.
Good stuff. IMO one of the things that should just work and is otherwise confusing for newcomers. Thanks! :)
Yeah if we allowing this new operator i think we can avoid guarding against it in the typechecker |
Will update this PR to remove check in the typechecker |
0b67366
to
a1d5a18
Compare
…-interpreted-as-operator
Good, looks cleaner now. |
The allowed custom operators are listed at https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/symbol-and-operator-reference/ . Which is this .md document in the docs repo: Could you please add it as well, since it is now an allowed pair? (and was not before) |
Sure. Will do it this week |
It looks like this new operator group |
Yes that is my understanding. @T-Gro For my own education which one is the correct here ? |
…ses (#16079) * Add analyzer & code fix for IDE0047 * Consistency * Consolidate lambda branches * Try-finally tweak * Fix * Fantomas * Explain * More Fantomas * Pass in getTextAtRange for № literals * Fantomas * Structs * Don't need that * Spaces * getTextAtRange → getSourceLineStr * Use `getSourceLineStr` and enable handling sensitive indentation inside parens. * Singleton * ↓ * Better * Streamline * One more * Don't need that here * Simplify lambda traversal * Add comment * Make private * Fix infix op tests * Add some more tests * Be (somewhat) more systematic about precedence, &c. * Represent precedence for more kinds of expression than just symbolic infix operators. * Handle exprs potentially confusable with type applications. * Handle more numeric literal cases. * Handle dangling nested exprs (`match`, `if`, &c.) * Consolidate SynPat logic * Comments * Space after backticks * Parens in interp hole * Submodule * Move extension method to common module * Expose raverseAll internally for clarity * Remove redundant arrow * Move diagnostic creation logic into its own file * We're still calling the logic directly inside of `DocumentDiagnosticAnalyzer` rather than exporting the type as an implementation of the `IFSharpUnnecessaryParenthesesDiagnosticAnalyzer` interface, since that interface does not exist upstream in Roslyn, and it seems like we would currently prefer not to go through the logistics of upstreaming it. * Fantomas * Remove comment * Apply Fantomas to tests * Include paren diagnostics in builder capacity * Update surface area * Remove unnecessary parens in DocumentDiagnosticAnalyzer tests * Add in-memory cache like SimplifyNameDiagnosticAnalyzer's * Update misleading comment * Ish * Might as well include the other example * The prefix op rules are tricky… * +Assorted other bits and bobs * Use existing helper method * More correct dangling expr logic * A few more tests for dangling exprs * Fix incomplete exprs * Missed that * Structness is immaterial here * Fantomas * Remove semi-misleading word * Add example to doc comment * Move ROS extensions to separate file in FCS * Use FS3583 instead of IDE0047 * Add example to comment * Fix find/replace in comments * Do the faster check first * Pretty sure we don't actually need that * Upon further thought, I'm pretty sure we _don't_ need to memoize the checking for dangling right-hand expressions, because we never dive deeper than needed for the check at hand, and the check will be quite shallow unless there are vast amounts of, say, nested matches inside of an if-condition body, but even then, such a check is both necessary and will only happen once, e.g.: ```fsharp let f x = if (match x with | _ -> match x with | _ -> match x with | _ -> match x with | _ -> match x with | _ -> if x then x else x) then x else x ``` If any other if-expression were found, or any nested parenthesized expression, or any construct without an exposed right-hand expression, the dive would end. * Fix (nonfunctional) copy/paste bug * Add tests for unmatched parens * Consolidate affixed infix tests for speed * Fantomas * Address a few more corner cases * Add basic ServiceAnalysis tests * Remove redundant assertions * Move some framework-y code to the framework file * Remove incorrect test * This test purported to test FS1182, but the actual diagnostic that is generated from the example is FS1183. * Don't need * A few more tests * Add a few attribute-related tests * Add test for new operator introduced in #15923 * Vars instead of consts * Add a few clarifying comments * Update tests/FSharp.Compiler.Service.Tests/UnnecessaryParenthesesTests.fs --------- Co-authored-by: Petr <[email protected]>
Attempts to fix #4607
Current Behaviour:
I'm learning my way through the Lexing and Parsing phase.
Updated
lex.fsl
andLexFilter.fs
With these changes you will be able to define
>:
as an operator that was not allowed before