mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-23 16:52:18 +01:00
Remove p[i] for ptr-typed p
This commit is contained in:
1 parent
1435f1d43c
commit
877b4f648f
4 files changed
+2
-13
No files matched your search
@@ -872,9 +872,6 @@ func (q *checker) bcheckExprOther(n *a.Expr, depth uint32) (*big.Int, *big.Int,
|
||||
lengthExpr := (*a.Expr)(nil)
|
||||
if lTyp := lhs.MType(); lTyp.IsArrayType() {
|
||||
lengthExpr = lTyp.ArrayLength()
|
||||
} else if lTyp.IsPtrType() {
|
||||
// TODO: don't skip bounds checking p[i] for ptr-typed p.
|
||||
break
|
||||
} else {
|
||||
lengthExpr = makeSliceLength(lhs)
|
||||
}
|
||||
@@ -894,7 +891,6 @@ func (q *checker) bcheckExprOther(n *a.Expr, depth uint32) (*big.Int, *big.Int,
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
// TODO: slicing "ptr T" types?
|
||||
lengthExpr := (*a.Expr)(nil)
|
||||
if lTyp := lhs.MType(); lTyp.IsArrayType() {
|
||||
lengthExpr = lTyp.ArrayLength()
|
||||
|
||||
+2
-3
@@ -467,8 +467,8 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
|
||||
return err
|
||||
}
|
||||
lTyp := lhs.MType()
|
||||
if key := lTyp.Decorator(); key != t.IDArray && key != t.IDPtr && key != t.IDSlice {
|
||||
return fmt.Errorf("check: %s is an index expression but %s has type %s, not an array, ptr or slice type",
|
||||
if key := lTyp.Decorator(); key != t.IDArray && key != t.IDSlice {
|
||||
return fmt.Errorf("check: %s is an index expression but %s has type %s, not an array or slice type",
|
||||
n.Str(q.tm), lhs.Str(q.tm), lTyp.Str(q.tm))
|
||||
}
|
||||
rTyp := rhs.MType()
|
||||
@@ -514,7 +514,6 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
|
||||
n.Str(q.tm), lhs.Str(q.tm), lTyp.Str(q.tm))
|
||||
case t.IDArray:
|
||||
n.SetMType(a.NewTypeExpr(t.IDSlice, 0, 0, nil, nil, lTyp.Inner()))
|
||||
// TODO: case t.IDPtr?
|
||||
case t.IDSlice:
|
||||
n.SetMType(lTyp)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user