-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix formatting of forward declared generics #5530
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
Merged
+23
−13
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to move this into parse somewhere in a way that makes it clear that it needs to be defined as true/false when adding new kinds of Nodes, so that Check can then just query it off the NodeKind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think nodes have support like that, and this seems pretty minor to add new support, but maybe I'm missing something; can you give a little more detail about what you're suggesting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I was thinking something like a
bool is_definition_start()
on theParse::NodeKind
struct here:carbon-lang/toolchain/parse/node_kind.h
Line 34 in 3946cac
So it could be added to
NodeKind::DefinitionArgs
with a default value of false but overridden to true in typed_nodes.h.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My perspective is that wouldn't need to be defined when adding new kinds, it just could be when people remember. We could do this by adding a
NodeCategory
, but I feel odd doing that when there's only one use, and any definition starts seem like they'll remain rare (and with handling specific to the formatter).We also already have
IsStartOfDeferredDefinitionScope
andIsEndOfDeferredDefinitionScope
in node_id_traversal.cpp, which feel similar; this keeps the check and logic close to the code using it.How strongly do you feel here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't think it's a win, then that's fine go with what you think is best. I thought that by having it in Parse, when adding something new I would at least have a hope of seeing all the things I need to set and think about which it is - and maybe copy/paste from a similar one too. Whereas over here, it's unlikely I will remember to set this correctly if I added a new node that should be
true
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is probably better. FWIW, my thought is it might be easier to notice here when adding printing of a new entity. If the entity doesn't need formatting, then it also doesn't need handling here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, I think I agree with Jon here, at least at this stage. The criteria I would use to sink this into Parse is there being more clients, especially if those are spread out somewhat.