#5478: rename bool branch selector voids so if results do not capture left and right#5497
#5478: rename bool branch selector voids so if results do not capture left and right#5497morphqdd wants to merge 2 commits into
Conversation
|
|
@yegor256, please look |
… not capture left and right
|
@maxonfjvipon look at this. It seems that we should get rid of the |
|
@yegor256 no, we just need other names instead of |
|
@yegor256 that's a known problem and should be caught by type inference |
|
@maxonfjvipon Thanks for the review! You've earned +4 points for this: +12 as a basis; -8 for absolutely no comments posted; -4 for too few (14) hits-of-code; +4 to give you at least something. Your running score is +633; don't forget to check your Zerocracy account too). |
|
@maxonfjvipon @yegor256 this PR already does exactly that: it renames the selector voids from On the "should be caught by type inference" point: I filed #5498 for exactly that follow-up (a lint that flags a formation whose void name collides with an attribute of the object it returns), since the same trap exists in other helpers like |
|



Closes #5478.
Root cause found. The result of every
if.is a copy of the branch selector formation fromtrue.eoandfalse.eo:The selector's voids are named
leftandright. Attribute lookup finds them before the phi fallthrough, so any dispatch of.leftor.righton anif.result hits the selector's own void instead of the method of the chosen branch. For the repro from the issue:magnitude.right 1takes the voidright(the already bound else branch, abytesobject) and then applies1to it, which lands in the already setdatavoid of thatbytes. That is exactly the reported error:This void attribute "data" is already set, can't reset. Sinceleftandrightare the shift methods ofbytes, every piece of integer arithmetic that first normalizes a value withif.and then shifts it was broken. This is what killed the composed pure-EO arithmetic in #5467, #5471 and thehash-code-offailure on #5475, withExpectreplacing this error by the generic type message.The names were introduced on 2026-06-09 in 8314d70 (the Church-encoded
boolfor #5189); nothing there suggests the capture was intended.The fix renames the selector voids to
left-branchandright-branch. All callers bind them positionally, so nothing else changes. Two regression tests inbool.eopin the behavior:.rightand.lefton anif.result now reach the chosen branch.Note for a follow-up: this is one instance of a general hazard. Any formation's void shadows the same-named attribute of the object it evaluates to, so every helper like
[condition body] > whileplants the same trap for.conditionand.body. A WPA lint that flags a void whose name collides with an attribute of the object it returns would catch the whole class. I can file that separately.Verification: full
eo-runtimebuild with lints and the whole test suite: 1505 tests, 0 failures, 0 errors; qulice clean.