mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 21:44:30 +02:00
[ruby/prism] Fix ..
and ...
to be non-associative
(https://github.com/ruby/prism/pull/1837)
Fix https://github.com/ruby/prism/pull/1829
90b0b1974c
Co-authored-by: Kevin Newton <kddnewton@gmail.com>
This commit is contained in:
parent
0aafd040c3
commit
ad25313ca8
2 changed files with 12 additions and 6 deletions
|
@ -10141,10 +10141,8 @@ typedef struct {
|
|||
bool binary;
|
||||
|
||||
/**
|
||||
* Whether or not this token can be used as non associative binary operator.
|
||||
* Usually, non associative operator can be handled by using the above left
|
||||
* and right binding powers, but some operators (e.g. in and =>) need special
|
||||
* treatment since they do not call parse_expression recursively.
|
||||
* Whether or not this token can be used as non-associative binary operator.
|
||||
* Non-associative operators (e.g. in and =>) need special treatment in parse_expression.
|
||||
*/
|
||||
bool nonassoc;
|
||||
} pm_binding_powers_t;
|
||||
|
@ -10193,8 +10191,8 @@ pm_binding_powers_t pm_binding_powers[PM_TOKEN_MAXIMUM] = {
|
|||
[PM_TOKEN_QUESTION_MARK] = RIGHT_ASSOCIATIVE(PM_BINDING_POWER_TERNARY),
|
||||
|
||||
// .. ...
|
||||
[PM_TOKEN_DOT_DOT] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_RANGE),
|
||||
[PM_TOKEN_DOT_DOT_DOT] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_RANGE),
|
||||
[PM_TOKEN_DOT_DOT] = NON_ASSOCIATIVE(PM_BINDING_POWER_RANGE),
|
||||
[PM_TOKEN_DOT_DOT_DOT] = NON_ASSOCIATIVE(PM_BINDING_POWER_RANGE),
|
||||
|
||||
// ||
|
||||
[PM_TOKEN_PIPE_PIPE] = LEFT_ASSOCIATIVE(PM_BINDING_POWER_LOGICAL_OR),
|
||||
|
|
|
@ -1708,6 +1708,14 @@ module Prism
|
|||
]
|
||||
end
|
||||
|
||||
def test_non_assoc_range
|
||||
source = '1....2'
|
||||
assert_errors expression(source), source, [
|
||||
['Expected a newline or semicolon after the statement', 4..4],
|
||||
['Cannot parse the expression', 4..4],
|
||||
]
|
||||
end
|
||||
|
||||
def test_upcase_end_in_def
|
||||
assert_warning_messages "def foo; END { }; end", [
|
||||
"END in method; use at_exit"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue