You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Swift: branch counts optional types and chaining (T?, x?.y), for as an argument label, and default/case outside a switch (precision 0.66) #8895
The Swift branch rule counts three things that are not decisions under the branch contract (docs/branch_rule_contract.md): optional types and optional chaining (T?, x?.y), for used as an argument label, and a default or case that is not in a switch. On vapor (1,906 Swift functions) the family fires in 267 functions where a parser sees no decision at all: recall 1.00, precision 0.66. Excluding those functions the precision is about 0.98, so the rule is otherwise sound. (The contract already fixed the same shape for other languages: "a generic wildcard (<?>) is a type, not a ternary"; ? is counted only as the ternary, and ?? as one value-selection decision.)
Reproduce (scanned with the pinned scanner)
structS{funcoptionalType(_x:Int?)->Int?{returnx} // branch == 2, should be 0 (two optional types)
funcchaining(_s:String?)->Int{returns?.count??0} // 3: the type `?`, the chain `?.`, and `??`; only `??` is a decision (1)
funclabelFor(foritem:Int)->Int{returnitem} // 1: `for` is an argument label, not a loop
funcrealIf(_a:Int)->Int{ifa>1{return1}; return0} // 1, correct
}
Expected
branch counts if/else/switch arms/loops/guard/the ternary ?/?? and not the ? of an optional type or chain, not a for label, and not a bare default/case outside a switch. Anchor the ? on ternary position (the contract's rule for java and ruby is the model) and the for on loop position.
How this was found
The keyword-family validity tool (#8864), by an oracle written for Swift under the epic's gate (the args and branch families must agree with the parser at 0.90 or better, to prove the oracle reads functions correctly): args passed at 0.98 / 1.00, branch recall passed at 1.00 and precision failed at 0.66, and the cause was traced to the engine's rule, not the oracle.
Part of #8863. Time the change (CPU seconds on keyword-rosetta and language-crucible); rosetta:rebless-owed if counts move; add the cases above as a test.
Claimed by promoter-bot host melek, lease renewed 2026-11-23T12:11Z. It lapses after 6 h without a renewal. To take it back, assign someone or remove the claim:melek label.
Activity
tests/tools: oracles for C#, Kotlin, Swift, Scala, Ruby, PHP, Lua and…
tests/tools: family_oracle scores each keyword family against an ast …
squid-protocol commentedon Nov 22, 2026
Claimed by promoter-bot host
melek, lease renewed 2026-11-23T12:11Z. It lapses after 6 h without a renewal. To take it back, assign someone or remove theclaim:meleklabel.re-bless gpu_json goldens after merging main (#8895)
squid-protocol commentedon Nov 23, 2026
Fixed by #9111 (merged as fcc440b), which carried this issue's PR (rebuilt with eight others to re-bless the golden snapshots once).