Skip to content

Commit

Permalink
[ruby/prism] Check void values in singleton class (class <<)
Browse files Browse the repository at this point in the history
Follow up the #8917 change.

ruby/prism@f6bac4d3bf
  • Loading branch information
makenowjust authored and matzbot committed Nov 22, 2023
1 parent 1f06d16 commit 6968b28
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion prism/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -14546,7 +14546,7 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power) {

if (accept1(parser, PM_TOKEN_LESS_LESS)) {
pm_token_t operator = parser->previous;
pm_node_t *expression = parse_expression(parser, PM_BINDING_POWER_NOT, PM_ERR_EXPECT_EXPRESSION_AFTER_LESS_LESS);
pm_node_t *expression = parse_value_expression(parser, PM_BINDING_POWER_NOT, PM_ERR_EXPECT_EXPRESSION_AFTER_LESS_LESS);

pm_parser_scope_push(parser, true);
accept2(parser, PM_TOKEN_NEWLINE, PM_TOKEN_SEMICOLON);
Expand Down
3 changes: 3 additions & 0 deletions test/prism/errors_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1508,6 +1508,8 @@ def test_void_value_expression_in_statement
end
class A < (return)
end
class << (return)
end
for x in (return)
end
RUBY
Expand All @@ -1520,6 +1522,7 @@ class A < (return)
[message, 80..86],
[message, 110..116],
[message, 132..138],
[message, 154..160],
], compare_ripper: false # Ripper does not check 'void value expression'.
end

Expand Down

0 comments on commit 6968b28

Please sign in to comment.