File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -343,7 +343,6 @@ fn parse_expr(cur: &mut Peekable<Iter<Token>>) -> Result<Expr> {
343343 match token {
344344 Token :: Integer ( i) => Expr :: Integer ( * i) ,
345345 Token :: String ( s) => Expr :: String ( s. clone ( ) ) ,
346- Token :: Bareword ( s) => Expr :: String ( s. clone ( ) ) ,
347346 Token :: Dollar => parse_dollar ( cur) ?,
348347 unexpected => {
349348 return Err ( ExecutionError :: ExpressionError ( format ! (
@@ -408,11 +407,15 @@ fn parse_variable(cur: &mut Peekable<Iter<Token>>) -> Result<Expr> {
408407
409408 match cur. next ( ) {
410409 Some ( Token :: OpenBracket ) => {
411- // TODO: I think there might be cases of $var{key} where key is a
412- // bareword. If that's the case, then handle here by checking
413- // if the next token is a bareword instead of trying to parse
414- // an expression.
415- let subfield = parse_expr ( cur) ?;
410+ // Allow bareword as string in subfield position
411+ let subfield = if let Some ( Token :: Bareword ( s) ) = cur. peek ( ) {
412+ cur. next ( ) ;
413+ Expr :: String ( s. clone ( ) )
414+ } else {
415+ // Parse the subfield expression
416+ parse_expr ( cur) ?
417+ } ;
418+
416419 let Some ( Token :: CloseBracket ) = cur. next ( ) else {
417420 return Err ( ExecutionError :: ExpressionError ( format ! (
418421 "unexpected token: {:?}" ,
You can’t perform that action at this time.
0 commit comments