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 Mar 1, 2024
1 parent d29d8ed commit 76f2317
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 @@ -261,7 +261,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
end
result = node.block.body ? evaluate(node.block.body, block_scope) : Types::NIL
block_scope.merge_jumps
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 @@ -680,6 +680,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 76f2317

Please sign in to comment.