Skip to content

Stop asserts crash on ivars in module_function methods - #165

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

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

Conversation

@apiology

@apiology apiology commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

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 castwide#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 changed the title Give module_function instance variable closures a source Stop asserts crash on ivars in module_function methods Oct 16, 2026
…vars

Brings in the 10 commits on castwide/master since this branch was
cut. No conflicts.
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