mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-22 08:47:28 +01:00
lang: allow "slice_var as ptr array[etc] etc"
This commit is contained in:
1 parent
6411561deb
commit
19f56ebfd2
7 files changed
+83
-5
No files matched your search
@@ -17,6 +17,7 @@ package check
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
a "github.com/google/wuffs/lang/ast"
|
||||
t "github.com/google/wuffs/lang/token"
|
||||
@@ -382,3 +383,15 @@ func (q *checker) proveRecvNotEqNullptr(recv *a.Expr) error {
|
||||
}
|
||||
return fmt.Errorf("check: cannot prove %q", recv.Str(q.tm)+" <> nullptr")
|
||||
}
|
||||
|
||||
func (q *checker) proveSliceLengthAtLeast(n *a.Expr, minInclLength *big.Int) error {
|
||||
if (n.Operator() == t.IDDotDot) && (n.MHS() == nil) && (n.RHS() == nil) {
|
||||
if lTyp := n.LHS().AsExpr().MType(); lTyp.IsEitherArrayType() &&
|
||||
lTyp.ArrayLength().ConstValue().Cmp(minInclLength) >= 0 {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
// TODO: the general case, where n isn't "foo[..]" and foo isn't an array
|
||||
// of length >= minInclLength.
|
||||
return fmt.Errorf("check: cannot prove %q", n.Str(q.tm)+".length() >= "+minInclLength.String())
|
||||
}
|
||||
Reference in new issue
Block a user