Skip to content

[regression fix] Stop asserts crash on ivars in module_function methods - #1429

Open
apiology wants to merge 2 commits into
castwide:masterfrom
apiology:namespace-pin-source-for-module-function-ivars
Open

apiology wants to merge 2 commits into
castwide:masterfrom
apiology:namespace-pin-source-for-module-function-ivars

Conversation

@apiology

Copy link
Copy Markdown
Contributor

Claude: This PR was written by Claude Code on behalf of @apiology.

Problem:

With SOLARGRAPH_ASSERTS=on, an ivar assigned in a module_function method crashes mapping:

module Functions
  module_function

  def foo
    # source not provided -   Solargraph::Pin::Namespace (RuntimeError)
    @foo ||= {}
  end
end

This aborts strong typechecking of any project that memoizes in a module_function method, including CacheDir.plugins in #1407.

Solution:

Give the module-scope closure pin source: :parser, as its sibling pins in ivasgn_node.rb already have.

IvasgnNode built the class-scope closure for an instance variable assigned
in a module_function method without source:, so SOLARGRAPH_ASSERTS=on
raised "source not provided" while mapping it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LDU6pFM33xXZg3WEppPqP6
@apiology
apiology marked this pull request as ready for review October 19, 2026 16:17
…vars

Brings in the 10 commits on castwide/master since this branch was
cut. No conflicts.
apiology added a commit to apiology/solargraph that referenced this pull request Oct 20, 2026
apiology added a commit to apiology/solargraph that referenced this pull request Oct 21, 2026
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.

1 participant