Skip to content

Conversation

he11olx
Copy link

@he11olx he11olx commented May 12, 2023

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
Copy link

CLAassistant commented May 12, 2023

CLA assistant check
All committers have signed the CLA.

@he11olx
Copy link
Author

he11olx commented May 12, 2023

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