Skip to content

Commit 39fb41f

Browse files
committed
Reverse-sync from upstream
1 parent b8f076a commit 39fb41f

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/prism.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11043,7 +11043,10 @@ parser_lex(pm_parser_t *parser) {
1104311043
}
1104411044

1104511045
if (lex_state_spcarg_p(parser, space_seen)) {
11046-
pm_parser_warn_token(parser, &parser->current, PM_WARN_AMBIGUOUS_SLASH);
11046+
// https://bugs.ruby-lang.org/issues/21994
11047+
if (parser->version <= PM_OPTIONS_VERSION_CRUBY_4_0) {
11048+
pm_parser_warn_token(parser, &parser->current, PM_WARN_AMBIGUOUS_SLASH);
11049+
}
1104711050
lex_mode_push_regexp(parser, '\0', '/');
1104811051
LEX(PM_TOKEN_REGEXP_BEGIN);
1104911052
}

test/prism/result/warnings_test.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ def test_ambiguous_ustar
1919
end
2020

2121
def test_ambiguous_regexp
22-
assert_warning("a /b/", "wrap regexp in parentheses")
22+
assert_warning("a /b/", "wrap regexp in parentheses", compare: false, version: "4.0")
23+
refute_warning("a /b/", compare: false, version: "4.1")
2324
end
2425

2526
def test_ambiguous_ampersand
@@ -408,8 +409,8 @@ def test_warnings_verbosity
408409
assert_equal "END in method; use at_exit", warning.message
409410
assert_equal :default, warning.level
410411

411-
warning = Prism.parse("foo /regexp/").warnings.first
412-
assert_equal "ambiguous `/`; wrap regexp in parentheses or add a space after `/` operator", warning.message
412+
warning = Prism.parse("foo +1").warnings.first
413+
assert_equal "ambiguous first argument; put parentheses or a space even after `+` operator", warning.message
413414
assert_equal :verbose, warning.level
414415
end
415416

0 commit comments

Comments
 (0)