Skip to content

branch: short-circuit boolean operators are counted in some languages and not others; Zig's rule lists && and || that Zig does not have #8905

Done

Description

@squid-protocol

What is wrong

Short-circuit boolean operators are counted as branch inconsistently across languages, and the contract is silent. The branch contract (docs/branch_rule_contract.md) names if/else/case/default/loops and the ternary and ?? value-selection operators; it says nothing about &&, ||, and or or. The engine's own rules disagree:

language boolean operators in the branch rule
C, C++, Go, JavaScript, Python (and, or), PowerShell (-and, -or, -xor) counted
Java not counted (11 Java functions in retrofit have a branch only through &&)
Solidity not counted (return a && b; scores branch 0)
Zig the rule lists && and `

The Zig entry is a dead pattern in either reading. The rest is a decision.

Reproduce

fn zig_and(a: bool, b: bool) bool { return a and b; }   // struct_branch == 0
contract C { function sol_and(bool a, bool b) public pure returns (bool) { return a && b; } }   // struct_branch == 0

Expected

Decide once whether a short-circuit boolean operator opens a runtime choice ("a keyword or operator that opens a runtime choice between control-flow paths": it arguably does, since the right operand runs only on one path), write it into the branch contract, and make every language's rule agree. If yes: add and/or for Zig (and drop the dead &&/||), and &&/|| for Java and Solidity; if no: remove them from C, C++, Go, JavaScript, Python and PowerShell.

Found by the keyword-family validity tool (#8864): the oracle counts boolean operators because the engine's C, Go and Python rules do, and the disagreement shows up as branch recall of 0.91 (Zig, Solidity) against 0.98-1.00 elsewhere.

Part of #8863. A contract decision first (#8862); then time each rule change.

Activity

  1. added
    bug
    question
    core-engine
    on Nov 21, 2026
  2. squid-protocol commented on Nov 21, 2026

    @squid-protocol
    OwnerAuthor

    Another language for the table: Groovy does not count && or || in branch (a && b || c scores 0, verified), so it joins Java, Solidity and Zig on the 'not counted' side while C, Go, Python and PowerShell count them.

  3. squid-protocol commented on Nov 21, 2026

    @squid-protocol
    OwnerAuthor

    Another language for the table: Nim does not count boolean and/or in branch (a and b or a scores 0, verified), joining Java, Solidity, Zig and Groovy on the 'not counted' side.

  4. squid-protocol commented on Nov 21, 2026

    @squid-protocol
    OwnerAuthor

    Decision (owner, 2026-11-21): boolean operators become their own leaf family short_circuit; branch keeps constructs and arms; composite decision_points = branch + short_circuit. Implemented in the draft PR linked below; it supersedes #8937 (Zig). Plan for the other broad families: docs/family_levels.md in that PR.

  5. squid-protocol commented on Nov 21, 2026

    @squid-protocol
    OwnerAuthor

    PR: #8939 (draft).

  6. squid-protocol commented on Nov 24, 2026

    @squid-protocol
    OwnerAuthor

    Claimed by promoter-bot host melek, lease renewed 2026-11-24T12:53Z. It lapses after 6 h without a renewal. To take it back, assign someone or remove the claim:melek label.

  7. squid-protocol commented on Nov 24, 2026

    @squid-protocol
    OwnerAuthor

    Verify-first check against main at beb46cf (after #8939): every row of the table is now decided.

    • Contract: docs/branch_rule_contract.md section 0 assigns boolean operators to the short_circuit family.
    • Each language's short_circuit rule is: C, C++, Go, JavaScript, Java, Solidity and Groovy &&|\|\|; Python, Zig and Nim \b(?:and|or)\b; PowerShell -and|-or|-xor.
    • The Zig branch rule is if|else|switch|while|for|orelse; the dead &&/|| is gone.
    • Repros (galaxyscope on the Zig, Solidity and Java snippets): each file scores struct_branch=0 and struct_short_circuit=1. The operator is counted in its own family, not in branch.

    No code change is needed; recommend closing as resolved by #8939.

  8. squid-protocol commented on Nov 24, 2026

    @squid-protocol
    OwnerAuthor

    Closing: every row of the table is decided on main by #8939 (short_circuit split); evidence in the worker's comment above.

  9. squid-protocol commented on Nov 24, 2026

    @squid-protocol
    OwnerAuthor

    Churn run 8905-20261124T1307Z (host melek) ended without a PR. already resolved by #8939; issue closed, no PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugclaim:melekcore-enginepriority: mediumquestion

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions