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

FCS 43.7.200 has odd behavior for modules with errors #14757

Closed
baronfel opened this issue Feb 15, 2023 · 8 comments
Closed

FCS 43.7.200 has odd behavior for modules with errors #14757

baronfel opened this issue Feb 15, 2023 · 8 comments

Comments

@baronfel
Copy link
Member

While updating FsAutoComplete to support F# 7 I found that something fundamental has changed in the way at least anonymous modules are parsed in the presence of errors. This leads to a large number of parse-tree-based helper methods for powering codefixes no longer functioning, and so many of the tests FSAC has validating codefix behavior are now permanently broken. For the codefixes I've directly investigated that have parallels in the VS tooling in this repo, I saw the same behavior using a VS 17.5 preview (to ensure I was on a similar FCS). Let's dig into one CodeFix in particular - the one that converts erroring single-quote string interpolation into triple-quoted interpolation.

Repro steps

Provide the steps required to reproduce the problem:

  1. Load up an .fsx file with the following content: let a = $":^) {if true then "y" else "n"} d"
  2. Note that a diagnostic 3373 is triggered at the " next to the y.
  3. Attempt to fire a codefix - none is found.
  4. The code that should trigger the codefix is TryRangeOfStringInterpolationContainingPos
  5. TryRangeOfStringInterpolationContainingPos isn't finding an interpolated string expression, why?
  6. There are no decls in the SynModuleOrNamespace:
    image

This is the case for many other codefixes, and they present the same way in VS as well.

@vzarytovskii
Copy link
Member

@nojaf @auduchinok does this ring a bell to you? I remember some changes around modules.

@vzarytovskii
Copy link
Member

vzarytovskii commented Feb 15, 2023

@baronfel in case if I need to bisect it, what would you say will be the fastest way of doing it? Do you have a FCS api snippet by any chance?

@baronfel
Copy link
Member Author

baronfel commented Feb 15, 2023

You should be able to debug it using the code string above and breakpointing here - VS has a codefix for interpolation as well (which is why I used it as the example). But the sample overall would be very simplistic:

  • create a script file/sourcetext with that content and get ProjectOptions for a script from FCS
  • parse the file
  • try to call the TryRangeOfStringInterpolationContainingPos API using the start position of the diagnostic returned by the parse
  • you get None, but you should get Some range.

@auduchinok
Copy link
Member

@nojaf @auduchinok does this ring a bell to you? I remember some changes around modules.

Nope, sorry. Maybe it could be related to PRs like #14399 or #14434?

@nojaf
Copy link
Contributor

nojaf commented Feb 16, 2023

This doesn't ring a bell, all I can say is that is happened between 7d115d5 and e30d14c.

@nojaf
Copy link
Contributor

nojaf commented Feb 16, 2023

Maybe #14182 is related. @abonie any thoughts?

@abonie
Copy link
Member

abonie commented Feb 16, 2023

Yes, it looks like the root cause as far as I can tell (idk how code fixes work, but second comment in that PR thread might explain how it broke it)

@0101
Copy link
Contributor

0101 commented Feb 27, 2023

The change that caused this was reverted (but not backported to 17.5). It should work in 17.6.

@0101 0101 closed this as completed Feb 27, 2023
@github-project-automation github-project-automation bot moved this from Not Planned to Done in F# Compiler and Tooling Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

6 participants