Replace "= try foo" with "=? foo"

This commit is contained in:
Nigel Tao committed 2018-12-01 13:11:47 +11:00
1 parent ad9851ea75
commit 9741eada02
14 files changed
+75 -82

No files matched your search

+1 -1
View File
@@ -769,7 +769,7 @@ func (q *checker) bcheckExprOther(n *a.Expr, depth uint32) (a.Bounds, error) {
}
}
case t.IDOpenParen, t.IDTry:
case t.IDOpenParen:
lhs := n.LHS().AsExpr()
if _, err := q.bcheckExpr(lhs, depth); err != nil {
return a.Bounds{}, err
+12 -12
View File
@@ -437,7 +437,7 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
return nil
}
case t.IDOpenParen, t.IDTry:
case t.IDOpenParen:
// n is a function call.
return q.tcheckExprCall(n, depth)
@@ -578,19 +578,19 @@ func (q *checker) tcheckExprCall(n *a.Expr, depth uint32) error {
setPlaceholderMBoundsMType(o.AsNode())
}
if n.Operator() == t.IDTry {
n.SetMType(typeExprStatus)
} else {
oTyp := f.Out()
if oTyp == nil {
n.SetMType(typeExprEmptyStruct)
} else if genericType1 != nil && oTyp.Eq(typeExprGeneric1) {
n.SetMType(genericType1)
} else if genericType2 != nil && oTyp.Eq(typeExprGeneric2) {
n.SetMType(genericType2)
oTyp := f.Out()
if oTyp == nil {
if n.Effect().Optional() {
n.SetMType(typeExprStatus)
} else {
n.SetMType(oTyp)
n.SetMType(typeExprEmptyStruct)
}
} else if genericType1 != nil && oTyp.Eq(typeExprGeneric1) {
n.SetMType(genericType1)
} else if genericType2 != nil && oTyp.Eq(typeExprGeneric2) {
n.SetMType(genericType2)
} else {
n.SetMType(oTyp)
}
return nil
}