Skip to content
New issue

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

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

Already on GitHub? # to your account

wire: can't handle varargs #61

Closed
ijt opened this issue Nov 5, 2018 · 3 comments
Closed

wire: can't handle varargs #61

ijt opened this issue Nov 5, 2018 · 3 comments
Assignees
Labels
enhancement New feature or request in progress This is being actively worked on
Milestone

Comments

@ijt
Copy link
Contributor

ijt commented Nov 5, 2018

Describe the bug

Wire can't handle functions with varargs.

To Reproduce

  1. Add a varargs parameter to a function, see for example

google/go-cloud@7cfcbb8

  1. Add a wire.Value entry to provide a concrete value for the parameter.

  2. Run wire.

Expected behavior

The Go file generated by wire should compile, but it doesn't.

https://travis-ci.com/google/go-cloud/jobs/156507298

Version

bf223a0

@vangent
Copy link
Contributor

vangent commented Nov 6, 2018

@zombiezen can you triage this and summarize what would need to be done to support it?

@zombiezen
Copy link
Collaborator

Based on the failure that @ijt provided, it appears that Wire is correctly determining the type in analysis, but is emitting incorrect code during the generation step. The change should be straightforward, as Wire changes go:

  1. Provider would need to grow a Varargs bool field to indicate that the last parameter of the provider function is variadic. This would need to be populated during the parse step.
  2. Similarly, call would need to grow a varargs bool field. This would be plumbed through during analysis.
  3. Finally, the information in the call.Varargs would be used in funcProviderCall to determine whether to append ... to the final argument.

This would be a good Wire starter project, as this plumbs a feature through the whole program.

@zombiezen
Copy link
Collaborator

@shantuo, want to try your hand at this issue?

@zombiezen zombiezen transferred this issue from google/go-cloud Nov 28, 2018
@zombiezen zombiezen added the enhancement New feature or request label Nov 28, 2018
@shantuo shantuo added the in progress This is being actively worked on label Nov 30, 2018
@shantuo shantuo added this to the Sprint 20 milestone Dec 1, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request in progress This is being actively worked on
Projects
None yet
Development

No branches or pull requests

4 participants