diff options
| author | Ufuk Kayserilioglu <ufuk.kayserilioglu@shopify.com> | 2023-12-07 01:36:00 +0200 |
|---|---|---|
| committer | Jemma Issroff <jemmaissroff@gmail.com> | 2023-12-11 09:47:33 -0500 |
| commit | 0562c246ebdf071dfb85b2f7904574d38fee14f7 (patch) | |
| tree | 9b5d46d9f2f4fbc3c5eaf6dd2370a54c6d776c46 /test | |
| parent | 48cb70fee95dcdcf5f9eef2ef40c3adfecc214fa (diff) | |
Add handling of implicit hash arguments
Arguments that are passed as a hash need special consideration since in certain case they are not treated as keyword arguments. For example, if a call is passing `"a" => 1` as an argument, this will be turned into an implicit hash argument and not a keyword argument.
The existing compiler checks to see if all hash nodes can be treated as keyword arguments. If they can, then it will treat them as keyword arguments. If not, then it will treat them as implicit hash arguments.
This commit implements the same logic inside the Prism compiler.
Diffstat (limited to 'test')
| -rw-r--r-- | test/ruby/test_compile_prism.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index c2cb60251c..13dd866313 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -1329,6 +1329,16 @@ module Prism end foo(1) CODE + + assert_prism_eval(<<-CODE) + def self.prism_opt_var_trail_hash(a = nil, *b, c, **d); end + prism_opt_var_trail_hash("a") + prism_opt_var_trail_hash("a", c: 1) + prism_opt_var_trail_hash("a", "b") + prism_opt_var_trail_hash("a", "b", "c") + prism_opt_var_trail_hash("a", "b", "c", c: 1) + prism_opt_var_trail_hash("a", "b", "c", "c" => 0, c: 1) + CODE end def test_CallAndWriteNode |
