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

Don't show completions on nested module identifier #13089

Merged
merged 23 commits into from
Mar 10, 2023
Merged

Conversation

kerams
Copy link
Contributor

@kerams kerams commented May 3, 2022

A simple fix.

module Namespace.Top

module Nest // =

This test is failing because without the equals sign Nest does not appear in the syntax tree at all. What exactly would it take to make this happen? I'm assuming something in the parser. Unfortunately, I am not yet familiar with that part of the compiler.

dsyme
dsyme previously approved these changes May 8, 2022
@dsyme
Copy link
Contributor

dsyme commented May 8, 2022

Code looks ok but the new test is still failing

@dsyme dsyme dismissed their stale review May 8, 2022 14:49

test still failing

@kerams
Copy link
Contributor Author

kerams commented May 8, 2022

I know and I have described why that is. Any clue on how to go about what I'm asking for?

@kerams
Copy link
Contributor Author

kerams commented May 17, 2022

Would it be necessary to add isFromErrorRecovery to SynModuleDecl.NestedModule (a la SynExpr.IfThenElse) to that end? Adding FromParseError does not seem like a good fit here.

For the sole reason that this nested module would appear in the syntax tree

namespace N

module Nested

@kerams
Copy link
Contributor Author

kerams commented Oct 27, 2022

Bump?

@vzarytovskii vzarytovskii requested a review from a team as a code owner October 27, 2022 14:34
@psfinaki
Copy link
Member

/azp run

@vzarytovskii
Copy link
Member

/run fantomas

@github-actions
Copy link
Contributor

@psfinaki psfinaki added this to the November-2022 milestone Oct 31, 2022
@psfinaki
Copy link
Member

@kerams if you want I might help with that later this week.

@kerams
Copy link
Contributor Author

kerams commented Nov 1, 2022

Well, first I want to know whether we're OK with extending the syntax tree just for this use case. If that isn't the case, the PR can be closed. Otherwise I only need a tip on the preferred approach with regards to modelling the error case.

@psfinaki
Copy link
Member

psfinaki commented Nov 1, 2022

Well from what I understand @dsyme is fine with that and nobody is against in general :)

@kerams
Copy link
Contributor Author

kerams commented Feb 9, 2023

I've added recovery for incomplete nested modules.

Before:

m99eoBsd6i

After:

prkSvMQG8M

@auduchinok, @nojaf , before I add tests and extend this to signature files, can you please check if the changes look sound to you?

@kerams
Copy link
Contributor Author

kerams commented Feb 9, 2023

Ugh, it doesn't work with ML compatibility mode

#indent "off"
module M

let SimpleSample() = 1

Is there a way to simulate a pattern guard in yacc?

| opt_attributes opt_access moduleIntro // when not mlSupport

Or maybe it's time this long-deprecated syntax was finally removed in .NET 8 SDK? :)

@nojaf
Copy link
Contributor

nojaf commented Feb 10, 2023

@auduchinok, @nojaf, before I add tests and extend this to signature files, can you please check if the changes look sound to you?

I think this looks fine, though I'm less familiar with recovery. I'll let @auduchinok take this one.

@kerams
Copy link
Contributor Author

kerams commented Feb 10, 2023

If I add recover at the end, #indent "off" works, but the original error on the following declaration is preserved. It's not a big deal, but it does not add any value with the new diagnostic.

image

@auduchinok
Copy link
Member

If I add recover at the end, #indent "off" works, but the original error on the following declaration is preserved. It's not a big deal, but it does not add any value with the new diagnostic.

If all is working by itself with recover added, then the additional error shouldn't be needed. Are there any other issues with recover added?

@kerams
Copy link
Contributor Author

kerams commented Feb 11, 2023

The Moon and the stars have aligned, ready for review.

@nojaf
Copy link
Contributor

nojaf commented Feb 11, 2023

As you changed the pars.fsy grammar rules, I would very much like to see a test in https://github.com/dotnet/fsharp/blob/main/tests/service/SyntaxTreeTests.fs where this new AST is constructed. Could you please an example file and a baseline file to https://github.com/dotnet/fsharp/tree/main/tests/service/data/SyntaxTree?

@nojaf
Copy link
Contributor

nojaf commented Feb 11, 2023

Thanks @kerams 🙏

Copy link
Member

@auduchinok auduchinok left a comment

Choose a reason for hiding this comment

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

@kerams I wonder if changes to LexFilter are still needed after you've changed recovery to use the builtin logic?

@T-Gro
Copy link
Member

T-Gro commented Feb 16, 2023

(updating to get the "short ranges" string representation in)

@psfinaki
Copy link
Member

@kerams this is ready to merge, right?

@kerams
Copy link
Contributor Author

kerams commented Mar 10, 2023

Yup.

Copy link
Member

@psfinaki psfinaki left a comment

Choose a reason for hiding this comment

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

Cool, thanks a lot!

@psfinaki psfinaki merged commit 695aacc into dotnet:main Mar 10, 2023
@kerams kerams deleted the mod branch March 10, 2023 16:40
kant2002 pushed a commit to kant2002/fsharp that referenced this pull request Apr 1, 2023
* Don't show completions on nested module identifier

* Recover from incomplete module declaration

* Blah

* Fixes

* Fix parser

* Fix parser

* Format

* Add AST tests

* Revert LexFilter changes

* Readd LexFilter

* Update baselines

* Format

* Update baselines

---------

Co-authored-by: Tomas Grosup <tomasgrosup@microsoft.com>
Sign up for free to 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.

7 participants