Repository navigation
fix: report a non-relation value passed as a transform's input instead of an internal error - #6585
Merged
Merged
Conversation
…d of an internal error A literal in a transform's relation position, such as `5 | select a` or `from t | derive x 5`, passed type checking (the array-type allowance in validate_type lets non-function values through) and reached the lineage lookup in resolve_function_args, whose fallback arm raised a location-less internal compiler error tracked at #4317. Report it as "expected a table or query, but found `5`" at the argument's span, as the empty `{}`/`[]` arms already do.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A literal in a transform's relation position —
5 | select a,from t | derive x 5,from t | take 1 "a",from foo | select lower "mooo"— now reports "expected a table or query, but found5" at the literal, instead of a location-lessinternal compiler error; tracked at https://github.com/PRQL/prql/issues/4317.Cause. Such a literal passes
validate_typeagainst therelationparam (the "temporary hack" there lets any non-function value through when an array type is expected), so it reaches the lineage lookup inresolve_function_args. That lookup's fallback arm raisedError::new_bug(4317); #5564 had replaced it with a proper error only for the empty{}/[]cases. The fallback arm now returns the sameExpectederror, describing the argument withwrite_pland spanned at the argument. Thevalidate_typeallowance itself is left alone, since it exists for window functions inderive/aggregate.Tests.
error_messages::non_relation_transform_inputcovers four of the forms above;task prqlc:testpasses. The comment onbad_error_messages::select_with_extra_fstr, which compares againstselect lower "mooo", now names the error that case gives. No conflict with #6525, which handles the reverse case (a table used as a value) inlowering.rs.