summaryrefslogtreecommitdiff
path: root/Zend/zend_compile.h
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-06-05 16:55:20 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-06-08 12:55:14 +0200
commitb03cafd19c01db57b89727ce77cc89a7d816077c (patch)
treeb8e39eeca2edf8fbb74e4b3fb7e2979470b959c0 /Zend/zend_compile.h
parent08518b18b2095b8c5158e272b4fe6c339f0eb1b7 (diff)
downloadphp-git-b03cafd19c01db57b89727ce77cc89a7d816077c.tar.gz
Fix bug #77966: Cannot alias a method named "namespace"
This is a bit tricky: In this cases we have "namespace as", which means that we will only recognize "namespace" as an identifier when the lookahead token is already at the "as". This means that zend_lex_tstring picks up the wrong identifier. We solve this by actually assigning the identifier as the semantic value on the parser stack -- as in almost all cases we will not actually need the identifier, this is just an (offset, size) reference, not a copy of the string. Additionally, we need to teach the lexer feedback mechanism used by tokenizer TOKEN_PARSE mode to apply feedback to something other than the very last token. To that purpose we pass through the token text and check the tokens in reverse order to find the right one. Closes GH-5668.
Diffstat (limited to 'Zend/zend_compile.h')
-rw-r--r--Zend/zend_compile.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h
index 9c6070d888..e11e6902b9 100644
--- a/Zend/zend_compile.h
+++ b/Zend/zend_compile.h
@@ -117,11 +117,17 @@ typedef struct _zend_file_context {
HashTable seen_symbols;
} zend_file_context;
+typedef struct {
+ uint32_t offset;
+ uint32_t len;
+} zend_lexer_ident_ref;
+
typedef union _zend_parser_stack_elem {
zend_ast *ast;
zend_string *str;
zend_ulong num;
unsigned char *ptr;
+ zend_lexer_ident_ref ident;
} zend_parser_stack_elem;
void zend_compile_top_stmt(zend_ast *ast);