-
Notifications
You must be signed in to change notification settings - Fork 611
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
wire: wire.Value is not forbidding references to names introduced in function scope #34
Comments
The README for wire says "It's important to note that the expression will be copied to the injector's package; references to variables will be evaluated during the injector package's initialization." So maybe this is not supported? The error message could be better. |
Link for sample is broken, and the imports are really relevant here. This sounds like a legit bug, though (the Wire value initialization time stuff is pretty now). Can you check that link? |
The new testcase MultipleSimilarPackages is easily modified to demonstrate this: vangent/go-cloud@ecd11e6#diff-08ca43f68146628973a3c5efdcb374e7 |
Ohhh. The issue is that Wire is not forbidding references to names introduced in function scope. Wire should throw an error in this case and not generate the code. I modified the issue description to make this more clear. |
Yea, the README explicitly says it's not supported but the error message doesn't tell you what you did wrong. Why can't we support this? |
It is technically feasible, but it makes the rule of " |
…n scope (google/go-cloud#405) Fixes google/go-cloud#378
See
https://github.com/vangent/go-cloud/tree/wirebug/wire/internal/wire/testdata/ValueFromStructField
for an example.
results in generated code
which fails with
cfg is out of scope in the generated code.
The text was updated successfully, but these errors were encountered: