Add value-returning match expressions

This commit is contained in:
pavel 2026-08-27 17:56:13 +02:00
commit ab783c33ed
12 changed files with 384 additions and 14 deletions

View file

@ -1144,6 +1144,15 @@ func exprMatches(expr Expr, match func(Expr) bool) bool {
return exprMatches(e.Receiver, match)
case IndexExpr:
return exprMatches(e.Receiver, match) || exprMatches(e.Index, match)
case MatchExpr:
if exprMatches(e.Value, match) {
return true
}
for _, matchCase := range e.Cases {
if exprMatches(matchCase.Value, match) {
return true
}
}
case LambdaExpr:
return stmtsMatch(e.Body, match)
}