summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEarlopain <14981592+Earlopain@users.noreply.github.com>2025-09-17 17:23:07 +0200
committergit <svn-admin@ruby-lang.org>2025-09-17 16:39:27 +0000
commit3c7a89721d53ba1cbe70a21cdf8a839b1aa16341 (patch)
treebf8cee50acee121c31cd742b7a6d0b9b31bf513f
parentc22d84a1211f139cbbb9b5fc00082e7b6a7c652e (diff)
[ruby/prism] Reject `1 if foo = bar baz`
and also `1 and foo = bar baz` This is a partial fix for https://github.com/ruby/prism/issues/3106 It still accepts `a = b c and 1` https://github.com/ruby/prism/commit/7a13d3535b
-rw-r--r--prism/prism.c2
-rw-r--r--test/prism/errors/command_calls_33.txt6
2 files changed, 7 insertions, 1 deletions
diff --git a/prism/prism.c b/prism/prism.c
index 2e202c3745..42a821e535 100644
--- a/prism/prism.c
+++ b/prism/prism.c
@@ -20909,7 +20909,7 @@ parse_assignment_values(pm_parser_t *parser, pm_binding_power_t previous_binding
bool permitted = true;
if (previous_binding_power != PM_BINDING_POWER_STATEMENT && match1(parser, PM_TOKEN_USTAR)) permitted = false;
- pm_node_t *value = parse_starred_expression(parser, binding_power, previous_binding_power == PM_BINDING_POWER_ASSIGNMENT ? accepts_command_call : previous_binding_power < PM_BINDING_POWER_MATCH, diag_id, (uint16_t) (depth + 1));
+ pm_node_t *value = parse_starred_expression(parser, binding_power, previous_binding_power == PM_BINDING_POWER_ASSIGNMENT ? accepts_command_call : previous_binding_power < PM_BINDING_POWER_MODIFIER, diag_id, (uint16_t) (depth + 1));
if (!permitted) pm_parser_err_node(parser, value, PM_ERR_UNEXPECTED_MULTI_WRITE);
parse_assignment_value_local(parser, value);
diff --git a/test/prism/errors/command_calls_33.txt b/test/prism/errors/command_calls_33.txt
new file mode 100644
index 0000000000..13e3b35c9e
--- /dev/null
+++ b/test/prism/errors/command_calls_33.txt
@@ -0,0 +1,6 @@
+1 if foo = bar baz
+ ^~~ unexpected local variable or method, expecting end-of-input
+
+1 and foo = bar baz
+ ^~~ unexpected local variable or method, expecting end-of-input
+