pkg/compiler: prohibit len of other union options

This commit is contained in:
Dmitry Vyukov 2018-02-23 14:00:41 +01:00
parent 7a7c747c6f
commit 5c1e020706
2 changed files with 10 additions and 1 deletions

View File

@ -256,8 +256,11 @@ func (comp *compiler) checkLenType(t *ast.Type, name string, fields []*ast.Field
}
checked[s.Name.Name] = true
parents = append(parents, s)
if !s.IsUnion {
fields = s.Fields
}
for _, fld := range s.Fields {
comp.checkLenType(fld.Type, fld.Name.Name, s.Fields, parents, checked, false)
comp.checkLenType(fld.Type, fld.Name.Name, fields, parents, checked, false)
}
return
}

View File

@ -73,8 +73,14 @@ s2 {
f1 s1
}
u1 [
f1 ptr[in, array[int8]]
f2 len[f1, int32] ### len target f1 does not exist
]
foo$200(a ptr[in, s2])
foo$201(a ptr[in, s1])
foo$202(a u1)
# Resource ctor tests.