Skip to content

Commit

Permalink
Always freeze #arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed Aug 22, 2020
1 parent 5b0eb14 commit 568095b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -12,6 +12,7 @@
### Changes

* [#94](https://github.com/rubocop-hq/rubocop-ast/pull/94): In Ruby 2.4, `Set#===` is harmonized with Ruby 2.5+ to call `include?`. ([@marcandre][])
* [#91](https://github.com/rubocop-hq/rubocop-ast/pull/x): **(Potentially breaking)** `Node#arguments` always returns a frozen array ([@marcandre][])

## 0.3.0 (2020-08-01)

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/ast/node/block_node.rb
Expand Up @@ -25,7 +25,7 @@ def send_node
# @return [Array<Node>]
def arguments
if numblock_type?
[] # Numbered parameters have no block arguments.
[].freeze # Numbered parameters have no block arguments.
else
node_parts[1]
end
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop/ast/node/mixin/parameterized_node.rb
Expand Up @@ -82,9 +82,9 @@ def arguments
# and optimizes other calls
module RestArguments
include ParameterizedNode
# @return [Array] arguments, if any
# @return [Array<Node>] arguments, if any
def arguments
children[first_argument_index..-1]
children[first_argument_index..-1].freeze
end

# A shorthand for getting the first argument of the node.
Expand Down

0 comments on commit 568095b

Please sign in to comment.