Skip to content

Conversation

@nojaf
Copy link
Contributor

@nojaf nojaf commented Jan 7, 2022

Fixes #2094.

The main problem was that the lhs parseState is unreliable if members are involved.
I tried to take a correct starting position and calculate the range by including all the member ranges.

While I was at it I noticed that there is a discrepancy between types in signature files and implementation files.
In signature files SynTypeDefnSig did include the type keyword in its range. While the counterpart SynTypeDefn does not.
The type keyword should (I think) only be included in SynModuleDecl.Types and SynModuleSigDecl.Types

//cc @dsyme

{ let needsCheck, (kind, decls) = $1
let objectModelRange =
match decls with
| [] -> lhs parseState
Copy link
Member

Choose a reason for hiding this comment

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

@nojaf Would it be hard to extract successfully ranges here too? Sorry, I should've added comment here too. 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would that be replacing it with rhs parseState 1?

Copy link
Member

Choose a reason for hiding this comment

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

From a glance, it seems it may require passing parsed ranges via tyconClassSpfn and other rules. Otherwise recovered ranges may still span further than they should. Not sure if you'd want to do that as a part of this PR. 🙂

It'd be great to do this systematically, the same as we've been fixing ranges of the things.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I see what you mean. I'm not going to push my luck in this current PR 😅.
I'll let it be while the PR is still green.

Copy link
Contributor

Choose a reason for hiding this comment

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

@nojaf , I will merge this as is, can you prepare a PR with the discussed modification and additional tests to cover that additional scenario please?

Thanks

Kevin

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey Kevin, thanks for merging this.
I can circle back to this in the future, @auduchinok any specific examples you can think of to cover this?

Copy link
Member

Choose a reason for hiding this comment

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

@nojaf Nope, I couldn't easily find an example. I'm going to look at members parser recovery later, and maybe I'll find an example. What happened in #12224 was it started returning intersecting ranges only after a better recovery was added to match clauses and patterns parsing, so it could probably happen here too.

@KevinRansom KevinRansom merged commit 70db5b0 into dotnet:main Jan 10, 2022
@nojaf nojaf deleted the fix-2094 branch January 10, 2022 19:21
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.

Parsed AST has incorrect ranges for Signature Files

4 participants