Skip to content

Conversation

@paracycle
Copy link
Member

@paracycle paracycle commented Jan 6, 2026

When merging trees, conflicts between a non-Scope node (e.g., G = C) and a Scope (e.g., class G < B; end) were not being detected. The Scope was simply added to the tree without creating a conflict marker.

This commit fixes two issues:

  1. TreeMerger#visit now handles the case where a Scope conflicts with a non-Scope previous definition. When this occurs, it creates a conflict tree and returns early (since the entire scope is in conflict, so there is no need to visit the children of the scope).
  2. ConflictTreeMerger#visit_all now resets last_conflict_tree when encountering a non-ConflictTree node. Previously, this variable was never reset, causing non-adjacent ConflictTrees to be incorrectly merged together.

For testing, this commit extends
test_merge_create_conflict_tree_constants_and_scopes to include a constant G = C in LHS and class G < B; end in RHS. The expected output now includes a conflict block for G showing both the constant assignment and class definition

When merging trees, conflicts between a non-Scope node (e.g., `G = C`)
and a Scope (e.g., `class G < B; end`) were not being detected. The
Scope was simply added to the tree without creating a conflict marker.

This commit fixes two issues:

1. `TreeMerger#visit` now handles the case where a Scope conflicts with
a non-Scope previous definition. When this occurs, it creates a conflict
tree and returns early (since the entire scope is in conflict, not just
the header).
2. `ConflictTreeMerger#visit_all` now resets `last_conflict_tree` when
encountering a non-`ConflictTree` node. Previously, this variable was
never reset, causing non-adjacent ConflictTrees to be incorrectly merged
together.

For testing, this commit extends
`test_merge_create_conflict_tree_constants_and_scopes` to include a
constant `G = C` in LHS and `class G < B; end` in RHS. The expected
output now includes a conflict block for G showing both the constant
assignment and class definition
@paracycle paracycle requested review from Morriar and egiurleo January 6, 2026 18:13
@paracycle paracycle requested a review from a team as a code owner January 6, 2026 18:13
@egiurleo egiurleo assigned egiurleo and unassigned egiurleo Jan 6, 2026
@paracycle paracycle merged commit 6261ea6 into main Jan 6, 2026
8 checks passed
@paracycle paracycle deleted the uk-smarter-constant-merge branch January 6, 2026 18:55
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.

4 participants