Skip to content

Commit e039762

Browse files
committed
toke.c:S_is_existing_identifier: Handle $_ @_
This calls scan_ident(), but that turns out to not handle these. Yet they are common constructs that we should consider. Add special handling for them.
1 parent 19ea4cf commit e039762

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

toke.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4476,6 +4476,16 @@ S_is_existing_identifier(pTHX_ char *s, char *e, bool is_utf8)
44764476

44774477
ptrdiff_t size = e - s;
44784478

4479+
/* Special case $_ and @_ because scan_ident() doesn't recognize them */
4480+
if ( LIKELY(sigil == '$' || sigil == '@')
4481+
&& size >= 2 && s[1] == '_' && s[0] == sigil
4482+
/* Make sure is the entire identifier, and not just a prefix to a
4483+
* longer one */
4484+
&& ! isIDCONT_lazy_if_safe( (U8 *) s + 2, (U8 *) e, UTF))
4485+
{
4486+
return 2;
4487+
}
4488+
44794489
/* khw: scan_ident appears to need a 2-byte minimum; easiest to just add
44804490
* that than calculate a minimum, Use 3 because we offset the output one
44814491
* byte to the right */

0 commit comments

Comments
 (0)