I have yet to use code blocks in Legend in a real scenario but I did experienced this issue as well!
In Legend’s defence, I don’t really see a situation where a code block (Used for it’s intended purpose) would have child?
But nonetheless, this is a bug and based on the fact that Legend is a blank slate where one can build practically anything, this issue will happen and should be addressed!