Remove p[i] for ptr-typed p

This commit is contained in:
Nigel Tao committed 2018-05-04 13:29:51 +10:00
1 parent 1435f1d43c
commit 877b4f648f
4 files changed
+2 -13

No files matched your search

-1
View File
@@ -20,7 +20,6 @@
- Renamed `buf1`, `reader1`, etc to `io_buffer`, `io_reader`, etc.
- Renamed `u32`, `io_reader`, etc to `base.u32`, `base.io_reader`, etc.
- Added a `base.image_config` type.
- Allow `p[i]` for pointer-typed `p`.
- Tweaked how marks and limits work.
- Supported animated (not just single frame) GIFs.
- Marked the `std/gif` LZW decoder as private.
-5
View File
@@ -727,11 +727,6 @@ func (n *TypeExpr) IsArrayType() bool {
return n.id0 == t.IDArray
}
func (n *TypeExpr) IsPtrType() bool {
// TODO: nptr??
return n.id0 == t.IDPtr
}
func (n *TypeExpr) IsSliceType() bool {
return n.id0 == t.IDSlice
}
-4
View File
@@ -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
View File
@@ -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)
}