Skip to content

Conversation

@max-sixty
Copy link
Member

Summary

Fixes #5661.

  • Fix crash when using partial application of transforms in user-defined functions (e.g., let foo = a -> take a)
  • Add documentation for partial application in the book
  • Add regression tests

The bug was in materialize_function: when wrapping a partially-applied inner function, the code was incorrectly truncating inner_closure.params. The fix keeps params intact and creates wrapper params with substitute argument expressions.

Test plan

  • task prqlc:pull-request passes
  • New regression test test_partial_application_of_transform validates the fix
  • Tested various partial application scenarios: take, derive, filter, composed pipelines

🤖 Generated with Claude Code

max-sixty and others added 2 commits January 6, 2026 13:26
Fixes PRQL#5661. When a user defines a function that wraps a transform with
fewer parameters than the transform requires (e.g., `let foo = a -> take a`),
the missing parameters are now correctly propagated to the wrapper function.

The bug was in `materialize_function`: when wrapping a partially-applied
inner function, it incorrectly truncated `inner_closure.params`. The fix
keeps params intact and adds substitute args that reference the wrapper's
parameters.

This enables patterns like:
- `let top_n = n -> take n` - wrap transforms with fewer params
- `let top_5 = top_n 5` - store fully-configured transforms
- `(top_n 5 | add_const 42)` - compose partial applications

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@max-sixty max-sixty merged commit a1c3f4c into PRQL:main Jan 6, 2026
36 checks passed
@max-sixty max-sixty deleted the 5661 branch January 6, 2026 21:46
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.

Compiler crash when aliasing a relational operator

1 participant