Skip to content

Commit

Permalink
Fix "Not enough arguments to" false positives on kwarg type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
apiology committed Oct 14, 2024
1 parent 524c94e commit 5eed247
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/solargraph/type_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ def call_problems
result
end

# @param chain [Solargraph::Source::Chain]
# @param api_map [Solargraph::ApiMap]
# @param block_pin [Solargraph::Pin::Base]
# @param locals [Array<Solargraph::Pin::Base>]
# @param location [Solargraph::Location]
def argument_problems_for chain, api_map, block_pin, locals, location
result = []
base = chain
Expand All @@ -279,9 +284,14 @@ def argument_problems_for chain, api_map, block_pin, locals, location
errors = []
sig.parameters.each_with_index do |par, idx|
argchain = base.links.last.arguments[idx]
if argchain.nil? && par.decl == :arg
errors.push Problem.new(location, "Not enough arguments to #{pin.path}")
next
if argchain.nil?
if par.decl == :arg
errors.push Problem.new(location, "Not enough arguments to #{pin.path}")
next
else
last = base.links.last.arguments.last
argchain = last if last && last.node.type == :kwsplat
end
end
if argchain
if par.decl != :arg
Expand Down

0 comments on commit 5eed247

Please sign in to comment.