Skip to content

Commit 04ab0c0

Browse files
Fixing the funclit pointer problem
1 parent b5ab57e commit 04ab0c0

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

build/build.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -945,14 +945,14 @@ func (s *Session) BuildProject(pkg *PackageData) (*compiler.Archive, error) {
945945
// getSortedSources returns the sources sorted by import path.
946946
// The files in the sources may still not be sorted yet.
947947
func (s *Session) getSortedSources() []*sources.Sources {
948-
srcs := make([]*sources.Sources, 0, len(s.sources))
949-
for _, src := range s.sources {
950-
srcs = append(srcs, src)
948+
allSources := make([]*sources.Sources, 0, len(s.sources))
949+
for _, srcs := range s.sources {
950+
allSources = append(allSources, srcs)
951951
}
952-
sort.Slice(srcs, func(i, j int) bool {
953-
return srcs[i].ImportPath < srcs[j].ImportPath
952+
sort.Slice(allSources, func(i, j int) bool {
953+
return allSources[i].ImportPath < allSources[j].ImportPath
954954
})
955-
return srcs
955+
return allSources
956956
}
957957

958958
func (s *Session) loadTestPackage(pkg *PackageData) (*sources.Sources, error) {

compiler/compiler_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,14 @@ func compileProject(t *testing.T, root *packages.Package, minify bool) map[strin
700700
}
701701

702702
tContext := types.NewContext()
703-
PrepareAllSources(allSrcs[root.PkgPath], allSrcs, importer, tContext)
703+
sortedSources := make([]*sources.Sources, 0, len(allSrcs))
704+
for _, srcs := range allSrcs {
705+
sortedSources = append(sortedSources, srcs)
706+
}
707+
sort.Slice(sortedSources, func(i, j int) bool {
708+
return sortedSources[i].ImportPath < sortedSources[j].ImportPath
709+
})
710+
PrepareAllSources(sortedSources, importer, tContext)
704711

705712
archives := map[string]*Archive{}
706713
for _, srcs := range allSrcs {

0 commit comments

Comments
 (0)