solargraph icon indicating copy to clipboard operation
solargraph copied to clipboard

Multiple keyword arguments with no default -> "Call to #foo is missing keyword argument"

Open apiology opened this issue 2 years ago • 6 comments

When I have multiple keyword arguments with no default, solargraph typecheck --level=strict gives a false positive:

broz@bigbookpro:~/src/repro-project$ cat > repro.rb
# @param i [Integer]
# @param s [Integer]
def foo(a:, b:)
end


foo(a: 123, b: 456)
broz@bigbookpro:~/src/repro-project$

solargraph typecheck --level=strict repro.rb gives the error:

/Users/broz/src/repro-project/repro.rb:7 - Call to #foo is missing keyword argument bCall to #foo is missing keyword argument b

This is surprising, as I am providing that argument:

foo(a: 123, b: 456)
Full repro session

broz@bigbookpro:~/src/repro-project$ solargraph typecheck --level=strict repro.rb [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Proc ^(K) -> V? [WARN] Unrecognized RBS type: RBS::Types::Proc ^(K) -> V? [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Intersection X & ::io [WARN] Unrecognized RBS type: RBS::Types::Intersection X & ::io [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Bases::Bottom bot [WARN] Unrecognized RBS type: RBS::Types::Proc ^(untyped) -> A [WARN] Unrecognized RBS type: RBS::Types::Proc ^(::Integer id) -> void [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Top top [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance [WARN] Unrecognized RBS type: RBS::Types::Bases::Instance instance /Users/broz/src/repro-project/repro.rb:7 - Call to #foo is missing keyword argument bCall to #foo is missing keyword argument b 1 problem found. broz@bigbookpro:~/src/repro-project$ solargraph typecheck repro.rb 0 problems found. broz@bigbookpro:~/src/repro-project$ solargraph --version 0.49.0 broz@bigbookpro:~/src/repro-project$

apiology avatar May 13 '23 17:05 apiology

Image Totally still a thing. Works flawlessly, but Solargraph can't see what's clearly there.

I would love to be able to suppress only this specific error at this specific position, like Rubocop allows so that once this bug is fixed — I'm not stuck with a spot that SG is blind to.

Erquint avatar May 26 '25 19:05 Erquint

You can use an @sg-ignore tag to suppress typechecking errors from the next line of code.

def example();end

# @sg-ignore
example(1, 2)

# solargraph typecheck will ignore the "too many arguments" error from the method call

castwide avatar May 26 '25 22:05 castwide

One tiny other thing I felt compelled to mention, the @sg-ignore tag also works when you add text to explain why it's necessary:

def example();end

# @sg-ignore We need to document the magic that makes arguments work here
example(1, 2)

castwide avatar May 26 '25 23:05 castwide

That's nonspecific. If I use @sg-ignore there and then this SG bug gets fixed — I will never know that it's no longer needed there. And if another kind of issue creeps into that line — I won't be getting informed of it by LSP. Accumulating indiscriminate warning suppressors in your code is not a great practice, especially as the semantic context changes with development.

Erquint avatar May 26 '25 23:05 Erquint

I see what you're saying. Unfortunately, there's currently no way to suppress typecheck errors with that level of granularity. I'm open to suggestions for making it more robust.

castwide avatar May 26 '25 23:05 castwide

What I referred to — drawing a parallel to RuboCop — was this: RuboCop Docs → Configuration → Disabling Cops within Source Code

Erquint avatar May 27 '25 00:05 Erquint