Skip to content

fix: re-import of identical package with sym.typ.cat == binPkgT#1551

Open
he11olx wants to merge 1 commit into
traefik:masterfrom
he11olx:fix-redeclare-import
Open

fix: re-import of identical package with sym.typ.cat == binPkgT#1551
he11olx wants to merge 1 commit into
traefik:masterfrom
he11olx:fix-redeclare-import

Conversation

@he11olx

@he11olx he11olx commented May 12, 2023

Copy link
Copy Markdown

test case:

func main() {
	script1 := `package script
import "encoding/json"
var _ = json.Marshal
`
	script2 := `package script
import "encoding/json"
var _ = json.Marshal
`
	inter := interp.New(interp.Options{GoPath: build.Default.GOPATH})
	_ = inter.Use(stdlib.Symbols)

	inter.Eval(script1)
	_, err := inter.Eval(script2)
	fmt.Println(err)
	// 2:8: json/_.go redeclared in this block
}

Related to: https://github.com/traefik/yaegi/pull/1066/files

sym.typ.cat == binPkgT
@CLAassistant

CLAassistant commented May 12, 2023

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@he11olx

he11olx commented May 12, 2023

Copy link
Copy Markdown
Author

Looks like not a bug but a feature. But In REPL, executing two import "fmt" will also report errors.

➜  yaegi
> import "fmt"
: 0x14000030120
> import "fmt"
1:21: fmt/_.go redeclared in this block

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants