1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[Bug #18884] class cannot be just followed by modifiers

This commit is contained in:
Nobuyoshi Nakada 2022-06-29 14:13:15 +09:00 committed by GitHub
parent 5e1c182900
commit 685efac059
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2022-06-29 14:13:36 +09:00
Merged: https://github.com/ruby/ruby/pull/6064

Merged-By: nobu <nobu@ruby-lang.org>
2 changed files with 8 additions and 1 deletions

View file

@ -9235,7 +9235,7 @@ parse_ident(struct parser_params *p, int c, int cmd_state)
return keyword_do_block; return keyword_do_block;
return keyword_do; return keyword_do;
} }
if (IS_lex_state_for(state, (EXPR_BEG | EXPR_LABELED))) if (IS_lex_state_for(state, (EXPR_BEG | EXPR_LABELED | EXPR_CLASS)))
return kw->id[0]; return kw->id[0];
else { else {
if (kw->id[0] != kw->id[1]) if (kw->id[0] != kw->id[1])

View file

@ -1359,6 +1359,13 @@ x = __ENCODING__
end; end;
end end
def test_if_after_class
assert_valid_syntax('module if true; Object end::Kernel; end')
assert_valid_syntax('module while true; break Object end::Kernel; end')
assert_valid_syntax('class if true; Object end::Kernel; end')
assert_valid_syntax('class while true; break Object end::Kernel; end')
end
=begin =begin
def test_past_scope_variable def test_past_scope_variable
assert_warning(/past scope/) {catch {|tag| eval("BEGIN{throw tag}; tap {a = 1}; a")}} assert_warning(/past scope/) {catch {|tag| eval("BEGIN{throw tag}; tap {a = 1}; a")}}