diff --git a/_test/const25.go b/_test/const25.go new file mode 100644 index 00000000..7cb053da --- /dev/null +++ b/_test/const25.go @@ -0,0 +1,11 @@ +package main + +const ( + FGBlack Attribute = iota + 30 +) + +type Attribute int + +func main() { + println(FGBlack) +} diff --git a/interp/cfg.go b/interp/cfg.go index d9a7d015..67a79caa 100644 --- a/interp/cfg.go +++ b/interp/cfg.go @@ -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: