You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the expr.WithContext option, the named variable must also be provided at compilation time using expr.Env, otherwise the patch seems to fail to correctly update calls to functions that require a context. (I'm not exactly sure why this happens, but if it's necessary, perhaps we should document it?)
With the expr.Env line commented out, this will fail (see playground), and with it uncommented, it succeeds (see playground). The error produced at runtime is:
reflect: Call with too few input arguments (1:1)
| cancelled()
| ^
Since this error also happens if cancelled is not bound at compilation but is bound at run, playground, I assume the problem is that Patch cannot figure out the argument of the function at compilation time.
Activity
[-]expr.WithContext Requires expr.Env[/-][+]expr.WithContext requires expr.Env?[/+]swdunlop commentedon Feb 8, 2025
Since this error also happens if
cancelledis not bound at compilation but is bound at run, playground, I assume the problem is that Patch cannot figure out the argument of the function at compilation time.antonmedv commentedon Mar 10, 2025
Yes, exactly. If patcher is not able to figure out the types, it will not add context arg.
But there is a way without a patcher: https://go.dev/play/p/zKG4Ro4jlo4