Merge pull request #324 from lizkammer/fix

Correct bug in generating anonymous nested props
This commit is contained in:
Liz Kammer 2020-10-05 17:08:52 -05:00 committed by GitHub
commit f20c9c3938
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -161,12 +161,13 @@ func assembleModuleTypeInfo(r *Reader, name string, factory reflect.Value,
} }
nestedName += proptools.PropertyNameForField(nested.Name) nestedName += proptools.PropertyNameForField(nested.Name)
nestedProp := ps.GetByName(nestedName) nestedProp := ps.GetByName(nestedName)
if nestedProp == nil { // Anonymous properties may have already been omitted, no need to ensure they are filtered later
return nil, fmt.Errorf("could not find nested property %q", nestedName) if nestedProp != nil {
} // Set property to anonymous to allow future filtering
nestedProp.SetAnonymous() nestedProp.SetAnonymous()
} }
} }
}
mt.PropertyStructs = append(mt.PropertyStructs, ps) mt.PropertyStructs = append(mt.PropertyStructs, ps)
} }