diff options
author | Jeremy Evans <[email protected]> | 2024-05-31 08:22:40 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2024-05-31 08:22:40 -0700 |
commit | 89486c79bb59216dbbbdff69a2c81cb387f64c5f (patch) | |
tree | 652773343005d1b40cf3a28f015d3d1a25c735d0 /test/ruby | |
parent | 8e2a6435e4f80f3c84cb7d8ac6d7a059d5969e1b (diff) |
Make error messages clear blocks/keywords are disallowed in index assignment
Blocks and keywords are allowed in regular index.
Also update NEWS to make this more clear.
Co-authored-by: Nobuyoshi Nakada <[email protected]>
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_call.rb | 6 | ||||
-rw-r--r-- | test/ruby/test_parse.rb | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/test/ruby/test_call.rb b/test/ruby/test_call.rb index a52b75c267..ced1eaf5e9 100644 --- a/test/ruby/test_call.rb +++ b/test/ruby/test_call.rb @@ -136,7 +136,7 @@ class TestCall < Test::Unit::TestCase # Prevent "assigned but unused variable" warnings _ = [h, a, kw, b] - message = /keyword arg given in index/ + message = /keyword arg given in index assignment/ # +=, without block, non-popped assert_syntax_error(%q{h[**kw] += 1}, message) @@ -270,7 +270,7 @@ class TestCall < Test::Unit::TestCase def o.[](...) 2 end def o.[]=(...) end - message = /keyword arg given in index/ + message = /keyword arg given in index assignment/ assert_syntax_error(%q{o[kw: 1] += 1}, message) assert_syntax_error(%q{o[**o] += 1}, message) @@ -292,7 +292,7 @@ class TestCall < Test::Unit::TestCase def []=(*a, **b) @set = [a, b] end end.new - message = /keyword arg given in index/ + message = /keyword arg given in index assignment/ a = [] kw = {} diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 3857f3cc17..20364c5a0d 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -512,12 +512,12 @@ class TestParse < Test::Unit::TestCase def t.dummy(_) end - assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /block arg given in index/) + assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /block arg given in index assignment/) begin; t[42, &blk] ||= 42 end; - assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /block arg given in index/) + assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /block arg given in index assignment/) begin; t[42, &blk] ||= t.dummy 42 # command_asgn test end; |