-
Notifications
You must be signed in to change notification settings - Fork 772
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
Parser: recover on unfinished qualified operator #16469
base: main
Are you sure you want to change the base?
Conversation
Well, this fix has turned out to be a breaking change, there's a test for
I have a serious doubt that it was purposefully added to the language, along with other I haven't ever seen any actual F# code written with these operators, and GitHub doesn't highlight them correctly either: let (.()) v1 v2 = v1 + v2
let _ = (.()) 1 2
let (.()<-) v1 v2 = v1 + v2
let _ = (.()<-) 1 2 |
I think there's a way to make it work for many cases without doing the breaking changes, but it'd be rather hacky in comparison with possible removing support for these hardcoded operators:
I'm wondering is there actually any known use of any of them? I think I've never seen anything like this:
|
@KevinRansom @dsyme any opinion on this? |
Let's unleash imagination of who could have used it by now - what about 'point-free style' fans who want to apply a collection indexer indexer in a point-free way? let (.()) (index:int) (array: _[]) = array[index]
let inline getFirstElementOfEvery arr = arr |> Array.map ((.()) 0 )
let firstIndices = getFirstElementOfEvery [| [|0|] ; [|1;0|] |] |
I think it was for future use if we wanted to allow users to have their own indexing operators for types. The following can't be defined in the user code: | ".[]"
| ".[]<-"
| ".[,]<-"
| ".[,,]<-"
| ".[,,,]<-"
| ".[,,,]"
| ".[,,]"
| ".[,]"
| ".[..]"
| ".[..,..]"
| ".[..,..,..]"
| ".[..,..,..,..]" These can: | ".()"
| ".()<-" |
Ok, now I remember where I've seen those. They are for ML compatibility for one: // Compile with --mlcompatibility
let op_ArrayLookup (a : int []) (i : int) =
a.[i]
let op_ArrayAssign (a : int []) (i : int) (v : int) =
a.[i] <- v
let a = [|1;2;3;4;5|]
a.(1) <- 9 ;
a.(1) |> ignore So, unless they're deprecated, we can't really get rid of them. |
@vzarytovskii Hm, I don't see any of these operators in your example. The concerns in this PR are only about these operators used without any spaces and IIRC in parens, like The example by @T-Gro is the only way I see of how they could be used in theory, but I'm not sure if it is documented or actually used anywhere. |
@auduchinok |
Or am I missing something? |
The problem in the parser rules faced by @auduchinok is only exposed when you use the operator WITHOUT putting in the arguments. .(0) => not a problem |
Documented not. Actually used - I am afraid we do not have a mechanism for answering that for private repositories. |
I personally think in the effort of providing better error recovery and tooling experience this should be considered. |
Caution Repository is on lockdown for maintenance, all merges are on hold. |
❗ Release notes requiredCaution No release notes found for the changed paths (see table below). Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format. The following format is recommended for this repository:
If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request. You can open this PR in browser to add release notes: open in github.dev
|
Adds parser recovery for some of the unfinished operators from #16260: