Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missed return statement in generated code #222

Closed
maratori opened this issue Nov 14, 2019 · 1 comment · Fixed by #223
Closed

Missed return statement in generated code #222

maratori opened this issue Nov 14, 2019 · 1 comment · Fixed by #223
Assignees
Labels
bug

Comments

@maratori
Copy link

@maratori maratori commented Nov 14, 2019

Bug description

Wire generates broken code. It generates function body without return statement.

To Reproduce

Run wire with following file

// +build wireinject

package storage

import "github.com/google/wire"

type MyInterface interface {
	Method()
}

type MyImplementation struct{}

func (MyImplementation) Method() {}

func XXX(MyImplementation) MyInterface {
	wire.Build(wire.Bind(new(MyInterface), new(MyImplementation)))
	return nil
}

It will generate following file

// Code generated by Wire. DO NOT EDIT.

//go:generate wire
//+build !wireinject

package storage

// Injectors from missed_return.go:

func XXX(myImplementation MyImplementation) MyInterface {

}

// missed_return.go:

type MyInterface interface {
	Method()
}

type MyImplementation struct{}

func (MyImplementation) Method() {}

Expected behavior

Wire should generate following file

//+build !wireinject

package storage

// Injectors from missed_return.go:

func XXX(myImplementation MyImplementation) MyInterface {
	return myImplementation
}

// missed_return.go:

type MyInterface interface {
	Method()
}

type MyImplementation struct{}

func (MyImplementation) Method() {}

Version

github.com/google/wire v0.3.0
go version go1.13 darwin/amd64

@zombiezen zombiezen self-assigned this Nov 14, 2019
@zombiezen zombiezen added the bug label Nov 14, 2019
@zombiezen
Copy link
Collaborator

@zombiezen zombiezen commented Nov 14, 2019

Thanks for the bug report! Expect a fix in the next week or so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants