mage icon indicating copy to clipboard operation
mage copied to clipboard

Bug: using Default with imports selects first matching func by name

Open na4ma4 opened this issue 1 year ago • 2 comments

Bug Description When using imports, namespaces and Default, the getFunction() function will return the first matching function in the import with the same name, regardless of namespacing.

So

// project magefile.go
var Default = mage.Test

// imported repo

type Docker mg.Namespace

func (Docker) Test() {
    log.Println("docker")
}

func Test() {
    log.Println("test")
}

Will find Docker.Test() before Test().

What did you do?

Created a test repository as an example

What did you expect to happen?

$ mage
test

What actually happened?

$ mage
docker

Environment

  • Mage Version: Mage Build Tool 1.15.0
  • OS: darwin/arm64

Additional context

na4ma4 avatar Jun 11 '24 07:06 na4ma4

ooh, thanks for the report and the repro steps

natefinch avatar Jun 12 '24 16:06 natefinch

I did a PR as well to fix it #509

na4ma4 avatar Aug 26 '24 01:08 na4ma4