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

Fix AshStub function matching for empty aggregates #2290

Merged
merged 1 commit into from
May 1, 2024

Conversation

oxc
Copy link
Contributor

@oxc oxc commented May 1, 2024

When calling an ash function from Javascript, the code tries to determine a type for empty arrays/aggregates based on the expected parameter type. It first matches the function with ANY type, and then passes a typeHint to the ValueConverter to generate an empty typed array/aggregate.

However, ANY type on the right hand side of a parameter match does not match with anything else than an ANY parameter. Instead, replace any ANY type values with the expected target type during matching, and replace it with the hinted empty aggregate in the second run.

Furthermore, the previous implementation effectively does nothing, since it did not used the values from the second run. Fix this, and improve performance by not converting all parameters twice even when no ANY types are used.

image

@oxc oxc requested a review from a team as a code owner May 1, 2024 10:00
When calling an ash function from Javascript, the code tries to
determine a type for empty arrays/aggregates based on the expected
parameter type. It first matches the function with ANY type, and then
passes a typeHint to the ValueConverter to generate an empty typed
array/aggregate.

However, ANY type on the right hand side of a parameter match does not
match with anything else than an ANY parameter. Instead, replace any ANY
type values with the expected target type during matching, and replace
it with the hinted empty aggregate in the second run.

Furthermore, the previous implementation effectively does nothing, since
it did not used the values from the second run. Fix this, and improve
performance by not converting all parameters twice even when no ANY
types are used.
@gausie gausie merged commit b06e4b9 into kolmafia:main May 1, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants