Repository navigation
Split blocks with more than two branches in functional - #165
Merged
Merged
Conversation
`functionalbranches!` only translated blocks ending in one or two branches and asserted otherwise, so blocks with a chain of conditional branches (e.g. from `x && y && error()`) failed. A chain of conditionals is a nested if/else, so split such blocks beforehand: keep the first branch and move the rest to a new block right after it, reached by an unconditional branch. Fixes #100. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #165 +/- ##
==========================================
+ Coverage 77.14% 77.69% +0.55%
==========================================
Files 15 16 +1
Lines 1597 1614 +17
==========================================
+ Hits 1232 1254 +22
+ Misses 365 360 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
CarloLucibello
force-pushed
the
cl/functional-multibranch
branch
from
October 15, 2026 15:56
5a23e2b to
499edcb
Compare
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.
Fixes #100.
functionalasserted that every block ends in at most two branches.f(x, y) = x && y && error()lowers to a block with three branches (br 4 unless %2; br 3 unless %3; br 2), so it failed withAssertionError: length(branches(bl)) == 2. A chain of conditional branches is just a nested if/else.functionalnow first splits such blocks: each one keeps its first branch and moves the rest into a new block placed right after it.The tests run the functional form through the existing
anfdynamo and compare it with the original function on all inputs:fabove, on all fourBoolcombinations;a && b && c && d && error(), on all 16 combinations;(The original
Dictgetindexexample from the issue already works on master.)🤖 Generated with Claude Code