Conversation
Solargraph generated a :kwarg (required) parameter pin for every member of a Struct.new(..., keyword_init: true) class, so typecheck --level strong reported "Missing keyword argument" when a call site omitted one. At runtime, keyword_init Struct members default to nil like ordinary Struct members, so they should be :kwoptarg (optional) instead. Fixes castwide#1268 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TqwAY5yf6K1ZQdYoSZDkmy
apiology
added a commit
to apiology/solargraph
that referenced
this pull request
Aug 6, 2026
apiology
marked this pull request as ready for review
August 6, 2026 18:37
3 tasks done
…word-init-optional
Removing it does not change strong typecheck output (531 problems, same set, before and after) -- inference already resolves this correctly, so no @sg-ignore is needed either.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
solargraph typecheck --level strongtreated every member of aStruct.new(..., keyword_init: true)-generated class as a required keyword argument, reporting a false "Missing keyword argument" error when a call site omitted one. At runtime,keyword_init: trueStruct members default tonilwhen omitted, exactly like ordinaryStruct.new(...)members.lib/solargraph/convention/struct_definition.rbgeneratedPin::Parameterpins for keyword-init Struct members withdecl: :kwarg(required). Changed todecl: :kwoptarg(optional), matching howTypeChecker#parameterized_arity_problems_foralready distinguishes required (:kwarg) from optional (:kwoptarg) keyword parameters.Data.define(lib/solargraph/convention/data_definition.rb) is untouched ��� its members genuinely are required at runtime, so:kwargstays correct there.Fixes #1268
Test plan
decl == :kwoptargbundle exec rspec(full suite): 1626 examples, 0 failuresbundle exec rubocopon changed files: no offensessolargraph typecheck --level strongagainst the issue's repro: 0 problems found (previously reported the false positive)���� Generated with Claude Code
https://claude.ai/code/session_01TqwAY5yf6K1ZQdYoSZDkmy