Project

General

Profile

Actions

Bug #18884

closed

parse.y: inconsistent parsing of "if" after "class"

Added by qnighy (Masaki Hara) over 1 year ago. Updated over 1 year ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
[ruby-core:109078]

Description

There is a corner case where if inconsistently causes a syntax error:

#  syntax error, unexpected `if' modifier
class if 1; Object end::Object
end

compare the following:

# Parses
module if 1; Object end::Kernel
end

We use EXPR_CLASS after the class keyword to temporarily disable heredocs as in class <<self; end. This state is expected to behave like EXPR_BEG in other cases but the above case fails to take it into account.

Actions

Also available in: Atom PDF

Like0
Like0