Skip to content

Fix fcall include handling with context-aware meta parsing#370

Merged
mame merged 1 commit intoruby:masterfrom
pvcresin:fix/fcall-include-context
Feb 18, 2026
Merged

Fix fcall include handling with context-aware meta parsing#370
mame merged 1 commit intoruby:masterfrom
pvcresin:fix/fcall-include-context

Conversation

@pvcresin
Copy link
Contributor

@pvcresin pvcresin commented Feb 17, 2026

This PR fixes scenario/known-issues/fcall-include.rb.

The known issue was this kind of code:

class C
  def include(x)
    x
  end

  def check
    include(1)
  end
end

TypeProf incorrectly treated include(1) as meta include in this context, so type inference became too loose.

Details

This PR fixes it by changing AST parsing:

  • Receiver-less include / attr_reader / attr_accessor are treated as meta only at class/module top level.
  • Calls in method bodies are parsed as normal method calls.

After this change:

  • The old known issue is moved to scenario/regressions/fcall-include.rb.
  • The scenario now passes as a regression test.

Limit include/attr_* meta parsing to class/module top-level statements and add a regression scenario for fcall include.

Co-authored-by: Cursor <cursoragent@cursor.com>
@pvcresin pvcresin force-pushed the fix/fcall-include-context branch from c28c8b1 to d74adf5 Compare February 17, 2026 13:20
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.

Neat solution!

@mame mame merged commit 6c06ab8 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