Skip to content

Parse rescue modifier values as statements#4133

Open
kddnewton wants to merge 1 commit into
mainfrom
rescue
Open

Parse rescue modifier values as statements#4133
kddnewton wants to merge 1 commit into
mainfrom
rescue

Conversation

@kddnewton

Copy link
Copy Markdown
Collaborator

The value of a rescue modifier is a full stmt in the grammar in three of its six productions, but we parsed it as a plain expression in every case. This rejected valid syntax such as a rescue b, c = 1 and accepted invalid syntax such as a = 1 rescue not b.

These are the relevant grammar rules:

  stmt            : stmt modifier_rescue stmt
                  | mlhs '=' mrhs_arg modifier_rescue stmt
  command_rhs     : command_call_value modifier_rescue stmt
  arg_rhs         : arg modifier_rescue arg
  endless_arg     : endless_arg modifier_rescue arg
  endless_command : endless_command modifier_rescue arg

parse_rescue_modifier_value will now parse either a stmt or an arg depending on the caller.

Supersedes #4128

The value of a `rescue` modifier is a full `stmt` in the grammar in
three of its six productions, but we parsed it as a plain expression
in every case. This rejected valid syntax such as `a rescue b, c = 1`
and accepted invalid syntax such as `a = 1 rescue not b`.

These are the relevant grammar rules:

      stmt            : stmt modifier_rescue stmt
                      | mlhs '=' mrhs_arg modifier_rescue stmt
      command_rhs     : command_call_value modifier_rescue stmt
      arg_rhs         : arg modifier_rescue arg
      endless_arg     : endless_arg modifier_rescue arg
      endless_command : endless_command modifier_rescue arg

parse_rescue_modifier_value will now parse either a stmt or an arg
depending on the caller.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant