Conversation
ForNode was unhandled in install_node, causing `for x in [1,2,3]` loop variables to resolve as untyped. This meant method calls on loop variables (e.g., `item.upcase`) could not be validated, leaving a gap in type coverage for idiomatic Ruby iteration patterns. Extract element type from Array[T] / Range[T] collection literals and register the loop variable in the current scope (no new scope, matching Ruby's for semantics). Return nil consistent with while/until handling. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
process_for_nodeinloops.rsto handleForNodeAST nodes, extracting element types fromArray[T]/Range[T]collection literals and registering loop variables in the current scopeForNodedispatch ininstall.rssoforloops are no longer silently ignoredWhy
ForNodewas completely unhandled in the AST installer —for x in [1, 2, 3]would silently skip type analysis, leaving loop variables untyped. This meant method calls likeitem.upcaseinsideforloops could not be validated, creating a gap in type coverage for Ruby code that usesforiteration.Design decisions
nil(consistent withwhile/until) rather than the collection, since the return value offoris rarely used in practiceforin Ruby does not create a block scope, so the loop variable correctly persists after the loopgenv.add_edge) for loop variable types, since they are determined at install time from literal collectionsTest plan
test_for_returns_nil,test_for_variable_type_from_array,test_for_variable_persists_after_loop,test_for_empty_body,test_for_with_method_call_in_bodytest_for_loop_basic_no_error,test_for_loop_detects_type_error🤖 Generated with Claude Code