fix: avoid a panic in CFG in case of incomplete type

By returning early in case of incomplete type in CFG, we avoid
a panic, and let a chance to a new attempt after the missing
type has been parsed.

Fixes 763.
This commit is contained in:
Marc Vertes
2020-07-09 13:05:04 +02:00
committed by GitHub
parent 640d1429e5
commit 16ff52a949
2 changed files with 20 additions and 0 deletions

17
_test/const15.go Normal file
View File

@@ -0,0 +1,17 @@
package main
type T1 t1
type t1 int8
const (
P2 T1 = 2
P3 T1 = 3
)
func main() {
println(P3)
}
// Output:
// 3

View File

@@ -476,6 +476,9 @@ func (interp *Interpreter) cfg(root *node, pkgID string) ([]*node, error) {
dest.typ = sc.fixType(src.typ)
}
}
if dest.typ.incomplete {
return
}
if dest.typ.sizedef {
dest.typ.size = arrayTypeLen(src)
dest.typ.rtype = nil