Add some ast.Expr.IsEtc methods

This commit is contained in:
Nigel Tao committed 2021-03-28 23:07:21 +11:00
1 parent b645180357
commit 41e407a774
7 files changed
+58 -48

No files matched your search

+3 -3
View File
@@ -55,16 +55,16 @@ func (q *checker) optimizeIOMethodAdvance(receiver *a.Expr, advance *big.Int, ad
// Check if receiver looks like "a[i .. j]" where i and j are constants and
// ((j - i) >= advance).
if receiver.Operator() == t.IDDotDot {
if _, i, j, ok := receiver.IsSlice(); ok {
icv := (*big.Int)(nil)
if i := receiver.MHS().AsExpr(); i == nil {
if i == nil {
icv = zero
} else if i.ConstValue() != nil {
icv = i.ConstValue()
}
jcv := (*big.Int)(nil)
if j := receiver.RHS().AsExpr(); (j != nil) && (j.ConstValue() != nil) {
if (j != nil) && (j.ConstValue() != nil) {
jcv = j.ConstValue()
}