Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Refactor #line processing - keep the original positions in the AST#18699

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Martin521 wants to merge14 commits intodotnet:main
base:main
Choose a base branch
Loading
fromMartin521:line-directives

Conversation

Martin521
Copy link
Contributor

@Martin521Martin521 commentedJun 18, 2025
edited
Loading

Description

Fixes#18553.
Breaking change.

This PR is non-breaking for two of the three #line use cases mentioned in#18553.
It keeps the original ranges in the AST, stores the #line directives in a table and provides a methodrange.ApplyLineDirectives(). This method is applied in the following places

  • construction of runtime diagnostics in pattern match compilation
  • emitting debug information in quotation translation
  • creating IL source markers (debug information)
  • formatting fsc compiler diagnostics (CompilerDiagnostics.FormatDiagnosticLocation)
  • creating service diagnostics (FSharpDiagnostics.CreateFromException)

This should make sure that all debugging information (in .pdb) and all diagnostics stay unchanged.

The third use case, symbol positions for IDE editors, is more tricky.FSharpSymbol has no range field or property that I could apply the transformation to, but just contains (and makes public) the AST items with their original ranges.
So, I propose we leave it like this and callApplyLineDirectives in the appropriate places in FSAC / the editors.
This will also enable better line directive support in the editors (for some use cases you need the original ranges).
For Ionide / FSAC I found that callingApplyLineDirectives in a single place (in FSAC'sfcsRangeToLspLocation) will most probably be sufficient to support the current functionality.
I don't know what it means for the other editors.
Any thoughts or recommendations here? (@TheAngryByrd@auduchinok@abonie )

List of breaking changes

  • For fsc and fcs users
    • __LINE__ and__SOURCE_FILE__ show original locations now
  • For fcs users only (tooling)
    • AST has original ranges now (ignoring #line directives) (so, alsoFSharpSymbol points to its original range)

Checklist

  • Test cases added
  • Performance benchmarks added in case of performance changes
  • Release notes entry updated

ijklam reacted with rocket emoji
@github-actionsGitHub Actions
Copy link
Contributor

github-actionsbot commentedJun 18, 2025
edited
Loading

❗ Release notes required


✅ Found changes and release notes in following paths:

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

@Martin521
Copy link
ContributorAuthor

Martin521 commentedJun 26, 2025
edited
Loading

This is ready for review. See updated PR description.
It introduces no changes for compiler users (except for the hardly used__LINE__ /__SOURCE_FILE__ in combination with#line).
For tooling, see the remarks above.

@Martin521Martin521 marked this pull request as ready for reviewJune 26, 2025 08:49
@Martin521Martin521 requested a review froma team as acode ownerJune 26, 2025 08:49
@Martin521
Copy link
ContributorAuthor

@T-Gro
Is there anything I can do to support reviewing this PR?

@TheAngryByrd
Copy link
Contributor

I expect this to not create any changes to the fsc output. I also assume there are no consumers of the compiler service that rely on having the target ranges in the AST. For them, this would be a breaking change. They would need to apply the map when dealing with these ranges.

Sorry for not getting around to responding sooner. We probably do with FSAC QuickFixes or possibly some analyzers but with all changes to FCS, we adapt. It might be enlightening to see what tests fail with a build of this against FSAC or FSharp.Analyzers.SDK/Ionide-Analyzers/GResearch's analyzers.

@Martin521
Copy link
ContributorAuthor

Sorry for not getting around to responding sooner. We probably do with FSAC QuickFixes or possibly some analyzers but with all changes to FCS, we adapt. It might be enlightening to see what tests fail with a build of this against FSAC or FSharp.Analyzers.SDK/Ionide-Analyzers/GResearch's analyzers.

Good to hear. Thanks for looking into it. I will try to run the tests and report back.

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

@nojafnojafnojaf left review comments

@edgarfgpedgarfgpedgarfgp approved these changes

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
Status: New
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Keep original line information in AST ranges, add separate mechanism for #line directives
4 participants
@Martin521@TheAngryByrd@nojaf@edgarfgp

[8]ページ先頭

©2009-2025 Movatter.jp