Skip to content

Commit

Permalink
Fix empty block args bug tap{||}
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng committed Oct 25, 2024
1 parent c9dfd60 commit 2c4389a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/repl_type_completor/type_analyzer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ def evaluate_call_node(node, scope)
when Prism::NumberedParametersNode
assign_numbered_parameters node.block.parameters.maximum, block_scope, block_args, {}
when Prism::BlockParametersNode
assign_parameters node.block.parameters.parameters, block_scope, block_args, {}
if node.block.parameters.parameters
assign_parameters node.block.parameters.parameters, block_scope, block_args, {}
end
when Prism::ItParametersNode
scope['_1'] = block_args.first || Types::NIL
end
Expand Down
1 change: 1 addition & 0 deletions test/repl_type_completor/test_type_analyze.rb
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ def test_call_parameter
end

def test_block_args
assert_call('[1,2,3].tap{|| 1.', include: Integer)
assert_call('[1,2,3].tap{|a| a.', include: Array)
assert_call('[1,2,3].tap{|a,| a.', include: Integer)
assert_call('[1,2,3].tap{|a,b| a.', include: Integer)
Expand Down

0 comments on commit 2c4389a

Please sign in to comment.