[ruby-core:88608] [Ruby trunk Bug#15018] NODE_ARGSCAT is not parsed properly

From: chopraanmol1@...
Date: 2018-08-22 12:11:01 UTC
List: ruby-core #88608
Issue #15018 has been reported by chopraanmol1 (Anmol Chopra).

----------------------------------------
Bug #15018: NODE_ARGSCAT is not parsed properly
https://bugs.ruby-lang.org/issues/15018

* Author: chopraanmol1 (Anmol Chopra)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.6.0dev (2018-08-22 trunk 64505) [x86_64-linux]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
Instead of wrapping following arguments in one list, current implementation creates multiple list wrapping only 2 elements.

e.g.
for

[*args,1,2,3,4,5,6]

Expected AST:

~~~
NODE_ARGSCAT---nd_head-->NODE_SPLAT(args)
|
|---nd_body-->NODE_ARRAY(1,2,3,4,5,6)

~~~
Current AST:
~~~

NODE_ARGSCAT---nd_head-->NODE_ARGSCAT--nd_head-->NODE_ARGSCAT--nd_head-->NODE_SPLAT(args)
|                          |                          |
|                          |                          |---nd_body-->NODE_ARRAY(1,2)
|                          |
|                          |---nd_body-->NODE_ARRAY(3,4)
|
|---nd_body-->NODE_ARRAY(5,6)
~~~

Current Implementation result into something like
~~~
args + [1,2] + [3,4] + [5,6]
~~~
instead of
~~~
args + [1,2,3,4,5,6]
~~~


Benchmark result
With patch:
~~~
                       user     system      total        real
argscat            0.556000   0.000000   0.556000 (  0.553981)
argscat_multiple   2.372000   0.000000   2.372000 (  2.373701)
~~~

Trunk:
~~~
                       user     system      total        real
argscat            1.656000   0.000000   1.656000 (  1.655868)
argscat_multiple   6.232000   0.000000   6.232000 (  6.234846)
~~~


Implementation:

https://github.com/ruby/ruby/pull/1940

---Files--------------------------------
bench_node_argscat.rb (524 Bytes)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next