Use "T[..inclMax]" instead of "T[:exclMax]".

This commit is contained in:
Nigel Tao committed 2017-05-20 15:11:30 +10:00
1 parent d3eba13223
commit 9184e2682e
9 files changed
+53 -44

No files matched your search

+3 -3
View File
@@ -348,14 +348,14 @@ func (q *checker) bcheckTypeExpr(n *a.TypeExpr) (*big.Int, *big.Int, error) {
return nil, nil, fmt.Errorf("check: internal error: unknown bounds for %q", n.String(q.idMap))
}
if n.IsRefined() {
if x := n.InclMin(); x != nil {
if x := n.Min(); x != nil {
if cv := x.ConstValue(); cv != nil && b[0].Cmp(cv) < 0 {
b[0] = cv
}
}
if x := n.ExclMax(); x != nil {
if x := n.Max(); x != nil {
if cv := x.ConstValue(); cv != nil && b[1].Cmp(cv) > 0 {
b[1] = sub1(cv)
b[1] = cv
}
}
}
+4 -4
View File
@@ -53,7 +53,7 @@ func TestCheck(t *testing.T) {
func foo.bar()() {
var x u8
var y i32 = +2
var z u64[:123]
var z u64[..123]
var a[4] u8
var b bool
@@ -66,7 +66,7 @@ func TestCheck(t *testing.T) {
y = x as i32
var p i32
var q i32[0:8]
var q i32[0..8]
assert true
@@ -129,11 +129,11 @@ func TestCheck(t *testing.T) {
{"in", "in"},
{"out", "out"},
{"p", "i32"},
{"q", "i32[0:8]"},
{"q", "i32[0..8]"},
{"this", "ptr foo"},
{"x", "u8"},
{"y", "i32"},
{"z", "u64[:123]"},
{"z", "u64[..123]"},
}
if !reflect.DeepEqual(got, want) {
t.Fatalf("\ngot %v\nwant %v", got, want)
+1 -1
View File
@@ -524,7 +524,7 @@ func (q *checker) tcheckTypeExpr(n *a.TypeExpr, depth uint32) error {
}
break
}
if n.InclMin() != nil || n.ExclMax() != nil {
if n.Min() != nil || n.Max() != nil {
// TODO: reject.
}
// TODO: see if name refers to a struct type.