Skip to content

Stop aborting typecheck on an unparseable method tag - #353

Draft
apiology wants to merge 1 commit into
masterfrom
degrade-unparseable-method-tags
Draft

apiology wants to merge 1 commit into
masterfrom
degrade-unparseable-method-tags

Conversation

@apiology

Copy link
Copy Markdown
Owner

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

Problem

A badly formed method tag raises instead of finding no methods:

api_map = Solargraph::ApiMap.new
# Solargraph::ComplexTypeError: Invalid close in type "a" => Float}{"b" => Float
api_map.get_method_stack('Hash{"a" => Float}{"b" => Float}', 'keys')

The tag comes from inference, so one type Solargraph rebuilds wrongly aborts a whole solargraph typecheck run instead of affecting one file.

Solution

Parse the tag with ComplexType.try_parse in ApiMap#get_method_stack and #inner_get_methods, as the sibling #get_methods already does, so it resolves to undefined and returns an empty method stack.

Extracted from castwide/solargraph#1231, intersection types.

ApiMap#get_method_stack and #inner_get_methods parsed their
inference-derived rooted_tag with ComplexType.parse, so a type
Solargraph reconstructed badly raised ComplexTypeError through
Chain#infer and aborted the whole typecheck run. Use try_parse, as
the sibling #get_methods already does: the tag resolves to undefined
and the caller gets an empty method stack.
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