Skip to content

Commit 9f31304

Browse files
committed
intuit_more: Check if identifier exists
The code attempted to do this, but was written before lexical variables existed, and had never been updated.
1 parent 5e9f082 commit 9f31304

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

toke.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4814,15 +4814,15 @@ S_intuit_more(pTHX_ char *s, char *e,
48144814
weight -= 100;
48154815
}
48164816
}
4817-
else if ( len > 1
4818-
/* khw: This only looks at global variables; lexicals
4819-
* came later, and this hasn't been updated. Ouch!!
4820-
* */
4821-
&& gv_fetchpvn_flags(tmpbuf + 1,
4822-
len,
4823-
UTF ? SVf_UTF8 : 0,
4824-
SVt_PV))
4825-
{
4817+
else if (len > 1) {
4818+
/* See if there is a known identifier of the given kind. For
4819+
* arrays, this might also be a reference to one of its
4820+
* elements. XXX Maybe the latter should require a following
4821+
* '[' */
4822+
if ( is_existing_identifier(tmpbuf, len, s[0], UTF)
4823+
|| ( s[0] == '$'
4824+
&& is_existing_identifier(tmpbuf, len, '@', UTF)))
4825+
{
48264826
weight -= 100;
48274827

48284828
/* khw: Below we keep track of repeated characters;
@@ -4835,6 +4835,16 @@ S_intuit_more(pTHX_ char *s, char *e,
48354835
* So, we should advance past it. Suppose it is a hash
48364836
* element, like $subscripts{$which}. We should advance
48374837
* past the braces and key */
4838+
}
4839+
else { /* Isn't a known identifier */
4840+
/* Under strict, this means an error. */
4841+
if (under_strict_vars) {
4842+
return false;
4843+
}
4844+
4845+
/* Otherwise still somewhat likely to be a subscript */
4846+
weight -= 10;
4847+
}
48384848
}
48394849
else if ( len == 1
48404850
&& s[0] == '$'

0 commit comments

Comments
 (0)