Skip to content

Commit d18a1da

Browse files
committed
docs(compiler): explain logical or asymmetry
Document why value-position || accepts a conditional left operand with a fallback right operand, and why the language does not add a matching && form in this PR.
1 parent f05c88a commit d18a1da

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

compiler/solver.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,9 @@ func (ts *TypeSolver) typeLogicalOrExpression(expr *ast.InfixExpression, left, r
15061506
if ts.InValueExpr {
15071507
// Value-position OR is asymmetric: the left operand must be able to
15081508
// fail, while the right operand may be another condition or a plain
1509-
// fallback value.
1509+
// fallback value. There is no matching value-position && because
1510+
// chained comparisons already refine a yielded value, and comma
1511+
// conditions provide statement-position AND.
15101512
if leftInfo == nil || !leftInfo.HasCondExpr() {
15111513
ts.Errors = append(ts.Errors, &token.CompileError{
15121514
Token: expr.Token,

0 commit comments

Comments
 (0)