interp: do not check properties of incomplete types

Fixes #1042.
This commit is contained in:
Marc Vertes
2021-03-09 11:58:04 +01:00
committed by GitHub
parent a988459dcd
commit fdfcb9c1df
2 changed files with 20 additions and 2 deletions

11
_test/const25.go Normal file
View File

@@ -0,0 +1,11 @@
package main
const (
FGBlack Attribute = iota + 30
)
type Attribute int
func main() {
println(FGBlack)
}

View File

@@ -82,8 +82,15 @@ func (interp *Interpreter) cfg(root *node, importPath string) ([]*node, error) {
i--
}
dest := a.child[i]
if dest.typ != nil && !isInterface(dest.typ) {
// Interface type are not propagated, and will be resolved at post-order.
if dest.typ == nil {
break
}
if dest.typ.incomplete {
err = n.cfgErrorf("invalid type declaration")
return false
}
if !isInterface(dest.typ) {
// Interface types are not propagated, and will be resolved at post-order.
n.typ = dest.typ
}
case binaryExpr, unaryExpr, parenExpr: