Skip to content

Fix keyword-as-hash handling for methods without keyword params#372

Merged
mame merged 1 commit intoruby:masterfrom
pvcresin:fix/keyword-as-hash
Feb 18, 2026
Merged

Fix keyword-as-hash handling for methods without keyword params#372
mame merged 1 commit intoruby:masterfrom
pvcresin:fix/keyword-as-hash

Conversation

@pvcresin
Copy link
Contributor

@pvcresin pvcresin commented Feb 17, 2026

This PR fixes TypeProf’s handling of calls like foo(x: 1) when the callee does not declare keyword parameters.(scenario/known-issues/keywords.rb.)

def foo(a)
  a
end

foo(x: 1)

In those cases, keyword arguments are now treated as a trailing positional hash (Ruby-compatible), improving inference from untyped to record/hash types.

Details

  • Track Prism::NoKeywordsParameterNode (**nil) as no_keywords in method AST metadata.
  • Add ActualArguments#with_keywords_as_last_positional_hash to centralize argument normalization.
  • Normalize keyword args in MethodDefBox#pass_arguments only when:
    • keyword args are present,
    • the method has no required/optional/rest keyword params,
    • and the method is not **nil.
  • Promote the scenario from scenario/known-issues/keywords.rb to scenario/args/keyword-as-hash.rb.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Member

@mame mame left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏👏👏

@mame mame merged commit c8011ef into ruby:master Feb 18, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments