diff options
author | TSUYUSATO Kitsune <make.just.on@gmail.com> | 2023-11-26 17:20:35 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-11-27 17:33:31 +0000 |
commit | 8654859dbd062af5071343effe48062123f356f7 (patch) | |
tree | b827991212488292bce01c8fd0f63bbeb9516d9d /test/prism/errors_test.rb | |
parent | bd4a992f38f59d15e325966a8e57f12559f331ad (diff) | |
download | ruby-8654859dbd062af5071343effe48062123f356f7.tar.gz |
[ruby/prism] Fix and reuse pm_call_node_index_p
Fix https://github.com/ruby/prism/pull/1925
Fix https://github.com/ruby/prism/pull/1927
Previously pm_call_node_index_p does not check about a block argument
correctly and is not used in parse_write to check an index call node.
This commit fixes these problems.
https://github.com/ruby/prism/commit/92bab044ff
Diffstat (limited to 'test/prism/errors_test.rb')
-rw-r--r-- | test/prism/errors_test.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/prism/errors_test.rb b/test/prism/errors_test.rb index 6f6df71d14..82f50edd6e 100644 --- a/test/prism/errors_test.rb +++ b/test/prism/errors_test.rb @@ -1256,6 +1256,33 @@ module Prism ] end + def test_index_call_with_block_and_write + source = "foo[1] {} &&= 1" + assert_errors expression(source), source, [ + ["Unexpected write target", 0..9], + ["Unexpected operator after a call with arguments", 10..13], + ["Unexpected operator after a call with a block", 10..13] + ] + end + + def test_index_call_with_block_or_write + source = "foo[1] {} ||= 1" + assert_errors expression(source), source, [ + ["Unexpected write target", 0..9], + ["Unexpected operator after a call with arguments", 10..13], + ["Unexpected operator after a call with a block", 10..13] + ] + end + + def test_index_call_with_block_operator_write + source = "foo[1] {} += 1" + assert_errors expression(source), source, [ + ["Unexpected write target", 0..9], + ["Unexpected operator after a call with arguments", 10..12], + ["Unexpected operator after a call with a block", 10..12] + ] + end + def test_writing_numbered_parameter assert_errors expression("-> { _1 = 0 }"), "-> { _1 = 0 }", [ ["_1 is reserved for a numbered parameter", 5..7] |