Skip to content

Commit

Permalink
Add check for nil otherTypeDef (#1372)
Browse files Browse the repository at this point in the history
fix bug: more than two models have the same short package name
  • Loading branch information
Evgeniy Gusev committed Oct 30, 2022
1 parent 38b5f15 commit 07690e9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages.go
Expand Up @@ -140,7 +140,10 @@ func (pkgDefs *PackagesDefinitions) parseTypesFromFile(astFile *ast.File, packag

anotherTypeDef, ok := pkgDefs.uniqueDefinitions[fullName]
if ok {
if typeSpecDef.PkgPath != anotherTypeDef.PkgPath {
if anotherTypeDef == nil {
typeSpecDef.NotUnique = true
pkgDefs.uniqueDefinitions[typeSpecDef.TypeName()] = typeSpecDef
} else if typeSpecDef.PkgPath != anotherTypeDef.PkgPath {
anotherTypeDef.NotUnique = true
typeSpecDef.NotUnique = true
pkgDefs.uniqueDefinitions[fullName] = nil
Expand Down Expand Up @@ -197,7 +200,10 @@ func (pkgDefs *PackagesDefinitions) parseFunctionScopedTypesFromFile(astFile *as

anotherTypeDef, ok := pkgDefs.uniqueDefinitions[fullName]
if ok {
if typeSpecDef.PkgPath != anotherTypeDef.PkgPath {
if anotherTypeDef == nil {
typeSpecDef.NotUnique = true
pkgDefs.uniqueDefinitions[typeSpecDef.TypeName()] = typeSpecDef
} else if typeSpecDef.PkgPath != anotherTypeDef.PkgPath {
anotherTypeDef.NotUnique = true
typeSpecDef.NotUnique = true
pkgDefs.uniqueDefinitions[fullName] = nil
Expand Down

0 comments on commit 07690e9

Please sign in to comment.