mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 13:34:17 +02:00
[ruby/prism] Change numbered parameters
Previously numbered parameters were a field on blocks and lambdas
that indicated the maximum number of numbered parameters in either
the block or lambda, respectively. However they also had a
parameters field that would always be nil in these cases.
This changes it so that we introduce a NumberedParametersNode that
goes in place of parameters, which has a single uint8_t maximum
field on it. That field contains the maximum numbered parameter in
either the block or lambda.
As a part of the PR, I'm introducing a new UInt8Field type that
can be used on nodes, which is just to make it a little more
explicit what the maximum values can be (the maximum is actually 9,
since it only goes up to _9). Plus we can do a couple of nice
things in serialization like just read a single byte.
2d87303903
This commit is contained in:
parent
90d9c20a0c
commit
cdb74d74af
205 changed files with 983 additions and 1361 deletions
|
@ -103,9 +103,14 @@ module Prism
|
|||
case node
|
||||
when BlockNode, DefNode, LambdaNode
|
||||
names = node.locals
|
||||
|
||||
params = node.parameters
|
||||
params = params&.parameters unless node.is_a?(DefNode)
|
||||
params =
|
||||
if node.is_a?(DefNode)
|
||||
node.parameters
|
||||
elsif node.parameters.is_a?(NumberedParametersNode)
|
||||
nil
|
||||
else
|
||||
node.parameters&.parameters
|
||||
end
|
||||
|
||||
# prism places parameters in the same order that they appear in the
|
||||
# source. CRuby places them in the order that they need to appear
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue