diff --git a/src/parser/hir/baseline_parse_tokens.rs b/src/parser/hir/baseline_parse_tokens.rs index 3f4b7868f..a04a06c5a 100644 --- a/src/parser/hir/baseline_parse_tokens.rs +++ b/src/parser/hir/baseline_parse_tokens.rs @@ -82,15 +82,43 @@ pub fn baseline_parse_next_expr( ExpressionKindHint::Block => { let span = (first.span.start, second.span.end); - let string: Spanned = match first { + let path: Spanned = match first { Spanned { item: hir::RawExpression::Literal(hir::Literal::Bare), span, - } => Spanned::from_item(span.slice(source).to_string(), span), + } => { + let string = Spanned::from_item(span.slice(source).to_string(), span); + let path = hir::Path::new( + Spanned::from_item( + // TODO: Deal with synthetic nodes that have no representation at all in source + hir::RawExpression::Variable(hir::Variable::It(Span::from((0, 0)))), + (0, 0), + ), + vec![string], + ); + let path = hir::RawExpression::Path(Box::new(path)); + Spanned { item: path, span: first.span } + } Spanned { item: hir::RawExpression::Literal(hir::Literal::String(inner)), span, - } => Spanned::from_item(inner.slice(source).to_string(), span), + } => { + let string = Spanned::from_item(inner.slice(source).to_string(), span); + let path = hir::Path::new( + Spanned::from_item( + // TODO: Deal with synthetic nodes that have no representation at all in source + hir::RawExpression::Variable(hir::Variable::It(Span::from((0, 0)))), + (0, 0), + ), + vec![string], + ); + let path = hir::RawExpression::Path(Box::new(path)); + Spanned { item: path, span: first.span } + } + Spanned { + item: hir::RawExpression::Variable(..), + .. + } => first, _ => { return Err(ShellError::unimplemented( "The first part of a block must be a string", @@ -98,17 +126,6 @@ pub fn baseline_parse_next_expr( } }; - let path = hir::Path::new( - Spanned::from_item( - // TODO: Deal with synthetic nodes that have no representation at all in source - hir::RawExpression::Variable(hir::Variable::It(Span::from((0, 0)))), - (0, 0), - ), - vec![string], - ); - let path = hir::RawExpression::Path(Box::new(path)); - let path = Spanned::from_item(path, first.span); - let binary = hir::Binary::new(path, *op, second); let binary = hir::RawExpression::Binary(Box::new(binary)); let binary = Spanned::from_item(binary, span);