File tree Expand file tree Collapse file tree 2 files changed +24
-13
lines changed
Expand file tree Collapse file tree 2 files changed +24
-13
lines changed Original file line number Diff line number Diff line change @@ -106,16 +106,21 @@ impl Resolver<'_> {
106106 // similarly as normal table references, we want to be able to infer columns
107107 // of this table, which means it needs to be defined somewhere
108108 // in the module structure.
109- let frame = self . declare_table_for_literal (
110- found
111- . clone ( )
112- . id
113- // This is quite rare but possible with something like
114- // `a -> b` at the moment.
115- . ok_or_else ( || Error :: new_bug ( 4280 ) ) ?,
116- None ,
117- found. alias . clone ( ) ,
118- ) ;
109+ let Some ( id) = found. id else {
110+ // Expression has no id - this happens with bare lambdas like `x -> y`
111+ let found_desc = match & found. kind {
112+ ExprKind :: Func ( _) => "a function" . to_string ( ) ,
113+ kind => format ! ( "{kind:?}" ) ,
114+ } ;
115+ return Err ( Error :: new ( Reason :: Expected {
116+ who : None ,
117+ expected : "a table" . to_string ( ) ,
118+ found : found_desc,
119+ } )
120+ . with_span ( found. span ) ) ;
121+ } ;
122+
123+ let frame = self . declare_table_for_literal ( id, None , found. alias . clone ( ) ) ;
119124
120125 // override the empty frame with frame of the new table
121126 found. lineage = Some ( frame)
Original file line number Diff line number Diff line change @@ -211,11 +211,17 @@ fn nested_groups() {
211211
212212#[ test]
213213fn a_arrow_b ( ) {
214- // This is fairly low priority, given how idiosyncratic the query is. If
215- // we find other cases, we should increase the priority.
216214 assert_snapshot ! ( compile( r###"
217215 x -> y
218- "### ) . unwrap_err( ) , @"Error: internal compiler error; tracked at https://github.com/PRQL/prql/issues/4280" ) ;
216+ "### ) . unwrap_err( ) , @r"
217+ Error:
218+ ╭─[ :2:5 ]
219+ │
220+ 2 │ x -> y
221+ │ ───┬──
222+ │ ╰──── expected a table, but found a function
223+ ───╯
224+ " ) ;
219225}
220226
221227#[ test]
You can’t perform that action at this time.
0 commit comments