Fix GH-23552: keyword class constant name not retagged to T_STRING - #305
Closed
iliaal wants to merge 1 commit into
Closed
Fix GH-23552: keyword class constant name not retagged to T_STRING#305iliaal wants to merge 1 commit into
iliaal wants to merge 1 commit into
Conversation
The tokenizer found the token a parser feedback applies to by scanning the collected token list backwards for a matching token text. Typed class constants defer reducing the constant name past the initializer scan, so for `const NEW = Bar::NEW;` the declaration's feedback re-found the initializer's token and left the declared name tagged T_NEW. Match the ident's source offset instead, accumulated as tokens are emitted. Text matching also inverted `const NEW = NEW Bar();`, retagging the NEW operator rather than the declaration, and its search could not fail, so the store is now guarded rather than asserted. Fixes phpGH-23552
Owner
Author
|
Promoted upstream as php#23618. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
class F { const NEW = Bar::NEW; }reportedT_NEWfor the declared name undertoken_get_all($code, TOKEN_PARSE). The tokenizer resolved a parser feedback by searching the collected token list backwards for a matching token text, and since 8.3 typed class constants defer reducing the constant name past the initializer scan, so the declaration's feedback re-found the initializer's token. Matching the ident's source offset instead also correctsconst NEW = NEW Bar();, where the text search retagged theNEWoperator and left the declaration alone.The offset is accumulated as tokens are emitted rather than derived from
LANG_SCNG(yy_cursor). The unterminated-comment rule returnsT_ERRORbefore recomputingyyleng, so the cursor overshoots the emitted length there; the test pins that input.