Skip to content
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

Add AddMissingFunKeyword code fix #10646

Merged
merged 2 commits into from
Dec 22, 2020

Conversation

cartermp
Copy link
Contributor

@cartermp cartermp commented Dec 8, 2020

This one was fun. Get it? har har har har har har har har har har har har har

Anyways, this is what it looks like:

image

And:

image

The fact that the error that triggers this is a parse error makes it so that we have to use our nice friend, Tokenizer.getSymbolAtPosition. We may want to consider moving that into FCS proper, since it lets you resolve a "symbol" without needing to parse or typecheck something. Very nice when you want the range of that "symbol".

@cartermp cartermp added this to the 16.9 milestone Dec 8, 2020
@alfonsogarciacaro
Copy link
Contributor

alfonsogarciacaro commented Dec 8, 2020

Can/Will this work with fat arrows? I guess that would be the common mistake made by newcomers. Scratch that, I just saw the other PR that handles that case.

else
loop (sourceText.GetSubText(TextSpan(pos - 1, 1)).ToString()) (pos - 1)

loop (sourceText.GetSubText(TextSpan(context.Span.Start - 1, 1)).ToString()) context.Span.Start
Copy link
Contributor

@TIHan TIHan Dec 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that the construction of TextSpan would receive any invalid input? Such as, context.Span.Start - 1 , would that result ever be -1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at this point, no. You can of course write literally -> as the first set of characters in a script file, but it won't trigger this error when that happens. The compiler thinks it's in the middle of a yield expression to be precise, which is weird, but unrelated to this or any other code fixer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry - it does trigger FS0010, but the span isn't actually ->, so it never reaches here in the first place

@cartermp cartermp requested a review from TIHan December 10, 2020 22:12
@cartermp cartermp closed this Dec 11, 2020
@cartermp cartermp reopened this Dec 11, 2020
@cartermp cartermp merged commit 6c11cb9 into dotnet:main Dec 22, 2020
@cartermp cartermp deleted the add-missing-fun-keyword-code-fix branch December 22, 2020 16:43
nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Feb 23, 2021
nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Jan 26, 2022
nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants