Skip to content

Better CE error reporting when using use! with and! - #17671

Merged
psfinaki merged 13 commits into
dotnet:mainfrom
edgarfgp:better-error-reporting-for-ce-use-and
Sep 10, 2024
Merged

Better CE error reporting when using use! with and!#17671
psfinaki merged 13 commits into
dotnet:mainfrom
edgarfgp:better-error-reporting-for-ce-use-and

Conversation

@edgarfgp

@edgarfgpedgarfgp commented Sep 8, 2024

Copy link
Copy Markdown
Contributor

Description

  • Improves the error range for use! may not be combined with and!
  • Updates SynExprAndBangTrivia to include also AndBangKeyword range
  • Uses only the and! range since it's what adds the error in the first place.

Before

Screenshot 2024-09-08 at 16 32 46

After

letrun r2 r3 =
result {use! b = r2
and! c = r3
^^^^return b - c
}

Checklist

  • Test cases added
  • Release notes entry updated

@edgarfgp
edgarfgp requested a review from a team as a code ownerSeptember 8, 2024 15:35
@github-actions

github-actionsBot commented Sep 8, 2024

Copy link
Copy Markdown
Contributor

❗ Release notes required


✅ Found changes and release notes in following paths:

Change pathRelease notes pathDescription
src/Compilerdocs/release-notes/.FSharp.Compiler.Service/9.0.100.md

@auduchinok

Copy link
Copy Markdown
Member

@edgarfgp Could it be better to highlight the and! part, since it's what adds the error? Could it also highlight the keyword only?

@edgarfgp

edgarfgp commented Sep 8, 2024

Copy link
Copy Markdown
ContributorAuthor

Could it be better to highlight the and! part, since it's what adds the error? Could it also highlight the keyword only?

Yeah I think that makes more sense. Thanks for the review.

Update: Unfortunately there is not a dedicated range for only the and keyword. So the best we can do for now if the expression range. See fantomas

@edgarfgp

Copy link
Copy Markdown
ContributorAuthor

@auduchinok I played around with your suggestion and I was able to update SynExprAndBangTrivia to also include and! range.

@edgarfgpedgarfgp closed this Sep 8, 2024
@edgarfgpedgarfgp reopened this Sep 8, 2024
Comment threadsrc/Compiler/SyntaxTree/SyntaxTree.fsi

@psfinakipsfinaki left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good stuff, I like this approach with adding trivia. Thanks for making diags better every week :)

@edgarfgp

Copy link
Copy Markdown
ContributorAuthor

@psfinaki I have more planned for CE in the upcoming weeks

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants

@edgarfgp@auduchinok@baronfel@vzarytovskii@psfinaki