Skip to content

Commit

Permalink
interp: do not check properties of incomplete types
Browse files Browse the repository at this point in the history
Fixes #1042.
  • Loading branch information
mvertes authored Mar 9, 2021
1 parent a988459 commit fdfcb9c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 11 additions & 0 deletions _test/const25.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

const (
FGBlack Attribute = iota + 30
)

type Attribute int

func main() {
println(FGBlack)
}
11 changes: 9 additions & 2 deletions interp/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit fdfcb9c

Please sign in to comment.