summaryrefslogtreecommitdiff
path: root/prism
diff options
context:
space:
mode:
authorKevin Newton <[email protected]>2024-09-13 12:47:33 -0400
committerKevin Newton <[email protected]>2024-09-13 14:09:02 -0400
commit77521afac1687602fde4046ab20f016c61089003 (patch)
treeab446cef387648ab6742eb89a1288187f338bfd9 /prism
parent9afc6a981deae6e23d938cf5c2c4baadfeaafdb1 (diff)
[PRISM] Do not warn ambiguous ampersand when symbol literal
Fixes [Bug #20735]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/11622
Diffstat (limited to 'prism')
-rw-r--r--prism/prism.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/prism/prism.c b/prism/prism.c
index c1ef8ed3d4..6d4d2f8199 100644
--- a/prism/prism.c
+++ b/prism/prism.c
@@ -11277,7 +11277,16 @@ parser_lex(pm_parser_t *parser) {
pm_token_type_t type = PM_TOKEN_AMPERSAND;
if (lex_state_spcarg_p(parser, space_seen)) {
- pm_parser_warn_token(parser, &parser->current, PM_WARN_AMBIGUOUS_PREFIX_AMPERSAND);
+ if ((peek(parser) != ':') || (peek_offset(parser, 1) == '\0')) {
+ pm_parser_warn_token(parser, &parser->current, PM_WARN_AMBIGUOUS_PREFIX_AMPERSAND);
+ } else {
+ const uint8_t delim = peek_offset(parser, 1);
+
+ if ((delim != '\'') && (delim != '"') && !char_is_identifier(parser, parser->current.end + 1)) {
+ pm_parser_warn_token(parser, &parser->current, PM_WARN_AMBIGUOUS_PREFIX_AMPERSAND);
+ }
+ }
+
type = PM_TOKEN_UAMPERSAND;
} else if (lex_state_beg_p(parser)) {
type = PM_TOKEN_UAMPERSAND;