-
Notifications
You must be signed in to change notification settings - Fork 601
Allow ${0x10}, ${0b10000} and ${0o20} to be used as aliases for $16 under use strict. #20014
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10195,18 +10195,52 @@ S_scan_ident(pTHX_ char *s, char *dest, STRLEN destlen, I32 ck_uni) | |
| } | ||
| } | ||
|
|
||
| /* special case to handle ${10}, ${11} the same way we handle ${1} etc */ | ||
| if (isDIGIT(*d)) { | ||
| bool is_zero= *d == '0' ? TRUE : FALSE; | ||
| /* special case to handle ${10}, ${11} the same way we handle $1 and ${1} etc, | ||
| * also special case ${0x10} and ${0b10000} to do the right thing and refer to | ||
| * $16 at compile time without triggering use strict violations */ | ||
| if (isDIGIT(*d) && s < PL_bufend) { | ||
| char *digit_start= d; | ||
| while (s < PL_bufend && isDIGIT(*s)) { | ||
| d++; | ||
| if (d >= e) | ||
| Perl_croak(aTHX_ "%s", ident_too_long); | ||
| *d= *s++; | ||
| bool has_leading_zero= *d == '0' ? TRUE : FALSE; | ||
| if (isDIGIT(*s)) { | ||
| do { | ||
| d++; | ||
| if (d >= e) | ||
| Perl_croak(aTHX_ "%s", ident_too_long); | ||
| *d = *s++; | ||
| } while (s < PL_bufend && isDIGIT(*s)); | ||
| if (has_leading_zero && d - digit_start >= 1) /* d points at the last digit */ | ||
| Perl_croak(aTHX_ ident_var_zero_multi_digit); | ||
| } | ||
| if (is_zero && d - digit_start >= 1) /* d points at the last digit */ | ||
| Perl_croak(aTHX_ ident_var_zero_multi_digit); | ||
| else | ||
| if ( has_leading_zero ) { | ||
| int shift = 0; | ||
| U8 class_bit = 0; | ||
| if (*s == 'x') { | ||
| shift = 4; | ||
| class_bit = CC_XDIGIT_; | ||
| } else if (*s == 'b') { | ||
| shift = 1; | ||
| class_bit = CC_BINDIGIT_; | ||
| } else if (*s == 'o') { | ||
| shift = 3; | ||
| class_bit = CC_OCTDIGIT_; | ||
| } | ||
| if (shift) { | ||
| STRLEN len = PL_bufend - s; | ||
| I32 flags = PERL_SCAN_SILENT_ILLDIGIT | PERL_SCAN_DISALLOW_PREFIX; | ||
| UV uv = Perl_grok_bin_oct_hex(aTHX_ s+1, &len, &flags, NULL, shift, class_bit, *s); | ||
| if (len) { | ||
| s += len + 1; /* move past the prefix digit and tail */ | ||
| if (flags & PERL_SCAN_GREATER_THAN_UV_MAX || d+len >= e) | ||
| Perl_croak(aTHX_ "%s", ident_too_long); | ||
|
Comment on lines
+10234
to
+10235
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing test for the |
||
| len = snprintf(dest,destlen, "%" UVuf, uv); | ||
| d = dest + len - 1; | ||
| /* note we dont need to worry about trailing garbage, that will be | ||
| * handled later. */ | ||
| } | ||
| } | ||
| } | ||
|
|
||
| d[1] = '\0'; | ||
| } | ||
|
|
||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider setting the
PERL_SCAN_ALLOW_UJNDERSCORESflag? (to allow things like0b11_00_1_1)