Project

General

Profile

Actions

Bug #18884

closed

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

Added by qnighy (Masaki Hara) over 2 years ago. Updated over 2 years 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 #1

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

  • Status changed from Open to Closed

Applied in changeset git|685efac05983dee44ce2d96c24f2fcb96a0aebe2.


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

Actions

Also available in: Atom PDF

Like0
Like0