fix: implicit import package name was not correctly generated
This commit is contained in:
committed by
Traefiker Bot
parent
1ff1a50753
commit
0d2c39d155
3
_test/foo-bar/foo-bar.go
Normal file
3
_test/foo-bar/foo-bar.go
Normal file
@@ -0,0 +1,3 @@
|
||||
package bar
|
||||
|
||||
var Name = "foo-bar"
|
||||
10
_test/import7.go
Normal file
10
_test/import7.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package main
|
||||
|
||||
import "github.com/containous/yaegi/_test/foo-bar"
|
||||
|
||||
func main() {
|
||||
println(bar.Name)
|
||||
}
|
||||
|
||||
// Output:
|
||||
// foo-bar
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"math"
|
||||
"path"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
@@ -32,6 +32,8 @@ var constBltn = map[string]func(*node){
|
||||
"real": realConst,
|
||||
}
|
||||
|
||||
var identifier = regexp.MustCompile(`([\pL_][\pL_\d]*)$`)
|
||||
|
||||
// cfg generates a control flow graph (CFG) from AST (wiring successors in AST)
|
||||
// and pre-compute frame sizes and indexes for all un-named (temporary) and named
|
||||
// variables. A list of nodes of init functions is returned.
|
||||
@@ -316,7 +318,7 @@ func (interp *Interpreter) cfg(root *node) ([]*node, error) {
|
||||
name = n.child[0].ident
|
||||
} else {
|
||||
ipath = n.child[0].rval.String()
|
||||
name = path.Base(ipath)
|
||||
name = identifier.FindString(ipath)
|
||||
}
|
||||
if interp.binPkg[ipath] != nil && name != "." {
|
||||
sc.sym[name] = &symbol{kind: pkgSym, typ: &itype{cat: binPkgT, path: ipath}}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package interp
|
||||
|
||||
import (
|
||||
"path"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
@@ -126,7 +125,7 @@ func (interp *Interpreter) gta(root *node, rpath string) ([]*node, error) {
|
||||
name = n.child[0].ident
|
||||
} else {
|
||||
ipath = n.child[0].rval.String()
|
||||
name = path.Base(ipath)
|
||||
name = identifier.FindString(ipath)
|
||||
}
|
||||
// Try to import a binary package first, or a source package
|
||||
if interp.binPkg[ipath] != nil {
|
||||
|
||||
Reference in New Issue
Block a user