Add value-returning match expressions
This commit is contained in:
parent
b0a52de4ea
commit
ab783c33ed
12 changed files with 384 additions and 14 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue