Skip to content

Commit

Permalink
Fixes #690
Browse files Browse the repository at this point in the history
  • Loading branch information
lu4p committed Dec 6, 2023
1 parent 0752f9e commit 5b46b02
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func (ri *reflectInspector) recordArgReflected(val ssa.Value, visited map[ssa.Va

case *ssa.ChangeType:
ri.recursivelyRecordUsedForReflect(val.X.Type())
case *ssa.Const:
case *ssa.MakeSlice, *ssa.MakeMap, *ssa.MakeChan, *ssa.Const:
ri.recursivelyRecordUsedForReflect(val.Type())
case *ssa.Global:
ri.recursivelyRecordUsedForReflect(val.Type())
Expand Down
53 changes: 53 additions & 0 deletions testdata/script/reflect.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"crypto/rand"
"crypto/x509"
"crypto/x509/pkix"
"encoding/gob"
"encoding/json"
"fmt"
"math/big"
Expand Down Expand Up @@ -410,6 +411,58 @@ type UnnamedStructFields struct {
}
}

func gobStruct() {
type gobAlias struct {
Security []map[string]struct {
List []string
Pad bool
}
}
alias := gobAlias{}

gob.NewEncoder(os.Stdout).Encode(alias)

alias.Security = make([]map[string]struct {
List []string
Pad bool
}, 0, len([]string{}))
}

func gobMap() {
type gobAlias struct {
Security map[string]struct {
List []string
Pad bool
}
}
alias := gobAlias{}

gob.NewEncoder(os.Stdout).Encode(alias)

alias.Security = make(map[string]struct {
List []string
Pad bool
}, len([]string{}))
}

func gobChan() {
type gobAlias struct {
Security chan struct {
List []string
Pad bool
}
}

alias := gobAlias{}

gob.NewEncoder(os.Stdout).Encode(alias)

alias.Security = make(chan struct {
List []string
Pad bool
}, len([]string{}))
}

-- importedpkg/imported.go --
package importedpkg

Expand Down

0 comments on commit 5b46b02

Please sign in to comment.