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

Make WithContext work for methods on env struct #602

Merged
merged 1 commit into from
Apr 12, 2024

Conversation

daenney
Copy link
Contributor

@daenney daenney commented Mar 12, 2024

This makes the WithContext patcher work when passing in a struct for an env that has methods that take a context.

This is a bit fiddly because we can't quite detect the difference of function vs. method on a struct, so we have to check both the first and the second param. Since it's highly unusual to pass the context as anything other than the first parameter, this should work out just fine in practice.

Fixes #600.

This makes the WithContext patcher work when passing in a struct for an
env that has methods that take a context.

This is a bit fiddly because we can't quite detect the difference of
function vs. method on a struct, so we have to check both the first and
the second param. Since it's highly unusual to pass the context as
anything other than the first parameter, this should work out just fine
in practice.

Fixes expr-lang#600.
@antonmedv antonmedv merged commit c0ad2d4 into expr-lang:master Apr 12, 2024
10 checks passed
antonmedv pushed a commit that referenced this pull request Apr 13, 2024
This makes the WithContext patcher work when passing in a struct for an
env that has methods that take a context.

This is a bit fiddly because we can't quite detect the difference of
function vs. method on a struct, so we have to check both the first and
the second param. Since it's highly unusual to pass the context as
anything other than the first parameter, this should work out just fine
in practice.

Fixes #600.
@daenney daenney deleted the context-env-struct branch April 13, 2024 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WithContext fails on env struct with method resulting in "not enough arguments to call"
2 participants