Parses a Let or a LetRec with the old order: Return first, and then CTEs in descending order.
(ctx: CtxRef, input: ParseStream)
| 191 | |
| 192 | /// Parses a Let or a LetRec with the old order: Return first, and then CTEs in descending order. |
| 193 | fn parse_let_or_letrec_old(ctx: CtxRef, input: ParseStream) -> Result { |
| 194 | let return_ = input.parse::<kw::Return>()?; |
| 195 | let parse_body = ParseChildren::new(input, return_.span().start()); |
| 196 | let body = parse_body.parse_one(ctx, parse_expr)?; |
| 197 | |
| 198 | let with = input.parse::<kw::With>()?; |
| 199 | let recursive = input.eat2(kw::Mutually, kw::Recursive); |
| 200 | let parse_ctes = ParseChildren::new(input, with.span().start()); |
| 201 | let mut ctes = parse_ctes.parse_many(ctx, parse_cte)?; |
| 202 | |
| 203 | if ctes.is_empty() { |
| 204 | let msg = "At least one Let/LetRec cte binding expected"; |
| 205 | Err(Error::new(input.span(), msg))? |
| 206 | } |
| 207 | |
| 208 | ctes.reverse(); |
| 209 | let cte_ids = ctes.iter().map(|(id, _, _)| id); |
| 210 | if !cte_ids.clone().is_sorted() { |
| 211 | let msg = format!( |
| 212 | "Error parsing Let/LetRec: seen Return before With, but cte ids are not ordered descending: {:?}", |
| 213 | cte_ids.collect::<Vec<_>>() |
| 214 | ); |
| 215 | Err(Error::new(input.span(), msg))? |
| 216 | } |
| 217 | build_let_or_let_rec(ctes, body, recursive, with) |
| 218 | } |
| 219 | |
| 220 | /// Parses a Let or a LetRec with the new order: CTEs first in ascending order, and then Return. |
| 221 | fn parse_let_or_letrec(ctx: CtxRef, input: ParseStream) -> Result { |
no test coverage detected