Repository navigation
fix(tree): let SetNodes accept a nil root - #1094
Merged
Merged
Conversation
Treat SetNodes(nil) as an empty tree, just like New(nil), so clearing the root doesn't panic when the tree renders. Add a regression test for clearing the root and check that a supplied root is preserved and rendered.
andrinoff
approved these changes
Nov 18, 2026
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.
Treat SetNodes(nil) as an empty tree, just like New(nil), so clearing the root doesn't panic when the tree renders.
Add a regression test for clearing the root and check that a supplied root is preserved and rendered.
CONTRIBUTING.md.fix(tree): accept a nil root in SetNodes
SetNodes(nil)reaches code that assumes a root exists. Substitute an empty root, matchingNew(nil). The regression updates a tree to a nil root and renders it.Open #1052 updates rendered values in SetValue. This fixes a separate nil-root failure in SetNodes, matching New(nil).
Separate tests cover positive behavior (
TestSetNodesRendersReplacement), negative controls (TestSetNodesPreservesSuppliedNode), and the regression (TestSetNodesNil). A representative regression fails on unchanged main and passes with the fix. The positive control passes on main; a deliberate break is also caught by the negative test.Validation on owner main
1deada954e6e, Go 1.26.10:-count=1 -cpu=1,4), plus 20 focused race repetitions.Cross-target binaries were compiled rather than executed. These are local results; remote CI remains to be confirmed.
usual disclosure applies; i'm working on my own harness, i use claude, claude root-caused thebug here that usrfaced during my work, i reviewed this, asked codex to review it, the patch is actualy super narrow, let me know if you have questions or mycode smells funny, i am super tired and my brin is a little melted, so i'll leave it here. i have another 8 or 10 to sendtomorrow.