Skip to content

Commit 16641d7

Browse files
thiremaniclaude
andcommitted
refactor(compiler): simplify isSlotAlignedSpine
Drop the two `info != nil` guards: the function reads info only after confirming expr is an *ast.InfixExpression, and the solver caches every infix node — it even reads a child's ExprInfo with no nil guard when caching the parent (solver.go:1822), so a missing entry would already have panicked there. info is never nil at these accesses. Drop the `IsComparison() || IsLogicalOr() -> false` branch. It was a defensive boundary to stop the recursion from descending into a comparison/|| node's operands, but a value-position comparison/|| always carries a cond mode (CondScalar/CondArray/CondOr), so the HasAnyComparison/HasFallbackOr true-check above it fires first for every expression the solver produces — the branch never decided an outcome. Easy to restore if cond-mode assignment ever changes. No behavior change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent c29de9e commit 16641d7

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

compiler/cond.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,15 +1214,12 @@ func (c *Compiler) isSlotAlignedSpine(expr ast.Expression) bool {
12141214
return false
12151215
}
12161216
info := c.ExprCache[key(c.FuncNameMangled, expr)]
1217-
if info != nil && len(c.pendingLoopRanges(info.Ranges)) > 0 {
1217+
if len(c.pendingLoopRanges(info.Ranges)) > 0 {
12181218
return false
12191219
}
1220-
if info != nil && (info.HasAnyComparison() || info.HasFallbackOr()) {
1220+
if info.HasAnyComparison() || info.HasFallbackOr() {
12211221
return true
12221222
}
1223-
if infix.Token.IsComparison() || infix.IsLogicalOr() {
1224-
return false
1225-
}
12261223
return c.isSlotAlignedSpine(infix.Left) || c.isSlotAlignedSpine(infix.Right)
12271224
}
12281225

0 commit comments

Comments
 (0)