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

CPP scope migration #2338

Merged
merged 22 commits into from
May 22, 2024
Merged

CPP scope migration #2338

merged 22 commits into from
May 22, 2024

Conversation

AndreasArvidsson
Copy link
Member

@AndreasArvidsson AndreasArvidsson commented May 17, 2024

Checklist

  • I have added tests
  • [/] I have updated the docs and cheatsheet
  • [/] I have not broken the cheatsheet

@AndreasArvidsson AndreasArvidsson requested a review from pokey as a code owner May 17, 2024 14:42
@AndreasArvidsson AndreasArvidsson changed the title Cpp Scope migration CPP scope migration May 17, 2024
@pokey
Copy link
Member

pokey commented May 17, 2024

started making some tweaks in 2ce105d because I noticed some incorrect scopes but ran out of steam. see the new scope fixtures; some are wrong

@AndreasArvidsson
Copy link
Member Author

AndreasArvidsson commented May 17, 2024

Good call. I made some fixes, but there are still some work left to do that will have to wait until tomorrow.

@AndreasArvidsson
Copy link
Member Author

@pokey I think this is ready now

@auscompgeek auscompgeek added the scope-migration Migrating scopes to next-gen scope implementation label May 18, 2024
Copy link
Member

@pokey pokey left a comment

Choose a reason for hiding this comment

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

Wow yeah getting these right requires work. I did a deep dive on class-like constructs (ie class, enum, struct, and union). I made sure those behave well for "type", "state", "class", "name", and "class name".

I ended up putting multiple scopes in a single file because otherwise the combinatorial explosion was pretty brutal. I know you are not a fan of that style, and I can see your case, but I'm not sure we should be dogmatic about it if it would result in dozens of files. Lmk what you think

Btw one advantage of putting multiple scopes in a single flie is that it can actually catch bugs. You had forgotten to anchor your semicolons to the statement they follow, so we had a bug where you would inadvertently treat two subsequent classes as a single class. Eg

struct aaa {};
struct bbb{};

Would result in one big class for both lines 😳. I was able to notice this because I had tests with multiple scopes, whereas it would not have been caught with a single scope

Anyways, merge if you're happy with my changes

queries/c.scm Outdated Show resolved Hide resolved
queries/c.scm Outdated Show resolved Hide resolved
queries/cpp.scm Outdated Show resolved Hide resolved
@AndreasArvidsson
Copy link
Member Author

Nicely done. In regards to anchoring the semicolon this is not something that we do in all places. If you search through the code base of scm files you find multiple places where we don't do this. Might of course be okay in those specific scenarios, but I do wonder if that is also an oversight?

@AndreasArvidsson AndreasArvidsson added this pull request to the merge queue May 22, 2024
Merged via the queue into main with commit 20d5ad1 May 22, 2024
15 checks passed
@AndreasArvidsson AndreasArvidsson deleted the cpp_migration branch May 22, 2024 15:46
@pokey
Copy link
Member

pokey commented May 22, 2024

Nicely done. In regards to anchoring the semicolon this is not something that we do in all places. If you search through the code base of scm files you find multiple places where we don't do this. Might of course be okay in those specific scenarios, but I do wonder if that is also an oversight?

It's a good question. It's possible it works in other places because of the way the hierarchy is. Eg the reason this fails is that the parser will create a series of statements and semicolons all as direct siblings. If other parse trees don't have this flat structure it should be fine. But agreed worth a grep to find examples and test them out at some point

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope-migration Migrating scopes to next-gen scope implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants