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

Spread values from an array to become the multiple args to coalesce() #5201

Open
philrz opened this issue Aug 5, 2024 · 0 comments
Open

Comments

@philrz
Copy link
Contributor

philrz commented Aug 5, 2024

tl;dr

I attempted this, but it's not currently possible.

$ zq 'const a = [null,2] yield coalesce(...a)'
zq: could not invoke zq with a single argument because:
 - a file could not be found with the name "const a = [null,2] y..."
 - the argument could not be compiled as a valid Zed query:
   error parsing Zed at line 1, column 36:
   const a = [null,2] yield coalesce(...a)
                                  === ^ ===

Details

Repro is with Zed commit c39086b.

I attempted this when working on this example shown in #5186.

@mattnibs gave a 👍 reaction to the idea, also adding:

In the semantic pass we do check if the number of arguments in a call match that of the declared function and return an error if not. You couldn't do that here but I don't think there's a problem returning an error in runtime. Just depends on how strict we want to be.

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

No branches or pull requests

1 participant