Skip to content

Commit

Permalink
fix: return correct package name for parsed package (#679)
Browse files Browse the repository at this point in the history
Co-authored-by: Marc Vertes <mvertes@free.fr>
  • Loading branch information
nrwiersma and mvertes committed Jun 10, 2020
1 parent 82b499a commit 36836cd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions interp/interp.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ type Interpreter struct {
universe *scope // interpreter global level scope
scopes map[string]*scope // package level scopes, indexed by package name
srcPkg imports // source packages used in interpreter, indexed by path
pkgNames map[string]string // package names, indexed by path
done chan struct{} // for cancellation of channel operations
}

Expand Down Expand Up @@ -213,6 +214,7 @@ func New(options Options) *Interpreter {
scopes: map[string]*scope{},
binPkg: Exports{"": map[string]reflect.Value{"_error": reflect.ValueOf((*_error)(nil))}},
srcPkg: imports{},
pkgNames: map[string]string{},
rdir: map[string]bool{},
}

Expand Down
3 changes: 2 additions & 1 deletion interp/src.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func (interp *Interpreter) importSrc(rPath, path string) (string, error) {
var err error

if interp.srcPkg[path] != nil {
return "", nil
return interp.pkgNames[path], nil
}

// For relative import paths in the form "./xxx" or "../xxx", the initial
Expand Down Expand Up @@ -111,6 +111,7 @@ func (interp *Interpreter) importSrc(rPath, path string) (string, error) {
// the global symbols in the package scope.
interp.mutex.Lock()
interp.srcPkg[path] = interp.scopes[path].sym
interp.pkgNames[path] = pkgName

interp.frame.mutex.Lock()
interp.resizeFrame()
Expand Down

0 comments on commit 36836cd

Please sign in to comment.