mirror of
https://github.com/golang/go
synced 2024-11-23 07:50:05 -07:00
go/types, types2: assert that builtin reports valid operand mode upon success
Fix a case where x.mode == invalid was returned despite builtin returning true. Change-Id: Iae9c18aac16bcbadc3530d341b380e05c8743fcc Reviewed-on: https://go-review.googlesource.com/c/go/+/495299 Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
66432e1b62
commit
8e3dfe783a
@ -200,12 +200,15 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
|
||||
}
|
||||
}
|
||||
|
||||
if mode == invalid && under(x.typ) != Typ[Invalid] {
|
||||
code := InvalidCap
|
||||
if id == _Len {
|
||||
code = InvalidLen
|
||||
if mode == invalid {
|
||||
// avoid error if underlying type is invalid
|
||||
if under(x.typ) != Typ[Invalid] {
|
||||
code := InvalidCap
|
||||
if id == _Len {
|
||||
code = InvalidLen
|
||||
}
|
||||
check.errorf(x, code, invalidArg+"%s for %s", x, bin.name)
|
||||
}
|
||||
check.errorf(x, code, invalidArg+"%s for %s", x, bin.name)
|
||||
return
|
||||
}
|
||||
|
||||
@ -850,6 +853,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
|
||||
unreachable()
|
||||
}
|
||||
|
||||
assert(x.mode != invalid)
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -201,12 +201,15 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
|
||||
}
|
||||
}
|
||||
|
||||
if mode == invalid && under(x.typ) != Typ[Invalid] {
|
||||
code := InvalidCap
|
||||
if id == _Len {
|
||||
code = InvalidLen
|
||||
if mode == invalid {
|
||||
// avoid error if underlying type is invalid
|
||||
if under(x.typ) != Typ[Invalid] {
|
||||
code := InvalidCap
|
||||
if id == _Len {
|
||||
code = InvalidLen
|
||||
}
|
||||
check.errorf(x, code, invalidArg+"%s for %s", x, bin.name)
|
||||
}
|
||||
check.errorf(x, code, invalidArg+"%s for %s", x, bin.name)
|
||||
return
|
||||
}
|
||||
|
||||
@ -851,6 +854,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
|
||||
unreachable()
|
||||
}
|
||||
|
||||
assert(x.mode != invalid)
|
||||
return true
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user