On invalid parse nodes, if the token may vary, allow any token. #3484
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.
Note #3486 rewrites the macro behavior, and is already approved: so this PR is only for the changed enforcement during error. Also, #3493 already changed several things to allow any token while this PR was awaiting review, but this still changes enforcement for
For
andIf
.This was brought up on #toolchain, and I think this any-on-error approach gets at least some support. We could try setting it to the introducer, but it's quite possible we want it to be something like the token which led to the parse error, rather than a static token. That leads to a conclusion that, most typically, we'll expect arbitrary tokens when error conditions may lead to tokens which aren't the expected token.
A couple related, recent
CARBON_IF_ERROR
crash fixes can be found in #3404 and #3424. Something like #3404 would've been needed regardless becausenamespace
didn't haveCARBON_IF_ERROR
before, although I might've missed the underlying issue with declarations because onlynamespace
had a relevant test (that is, if #3404 had addedCARBON_ANY_TOKEN_ON_ERROR
, I wouldn't have had a crash in #3462). #3424 would've been avoided with this change because there was aCARBON_IF_ERROR
, and it was just too restrictive.