Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix empty block args bug tap{||} #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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