From 73aae2714870f94d8ab8ad08ec6c423b09583b1e Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Thu, 6 Jan 2022 19:53:10 -0500 Subject: [PATCH] Fix crash on empty files() statement --- mps-interpreter/src/lang/vocabulary/files.rs | 28 ++++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/mps-interpreter/src/lang/vocabulary/files.rs b/mps-interpreter/src/lang/vocabulary/files.rs index 871ca44..9605c54 100644 --- a/mps-interpreter/src/lang/vocabulary/files.rs +++ b/mps-interpreter/src/lang/vocabulary/files.rs @@ -125,21 +125,21 @@ impl MpsFunctionFactory for FilesFunctionFactory { let mut root_path = None; let mut pattern = None; let mut recursive = None; - if tokens[0].is_literal() { - // folder is specified without keyword - root_path = Some(assert_token( - |t| match t { - MpsToken::Literal(s) => Some(s), - _ => None, - }, - MpsToken::Literal("/path/to/music/folder".into()), - tokens, - )?); - if tokens.len() > 1 && tokens[0].is_comma() { - assert_token_raw(MpsToken::Comma, tokens)?; - } - } if tokens.len() != 0 { + if tokens[0].is_literal() { + // folder is specified without keyword + root_path = Some(assert_token( + |t| match t { + MpsToken::Literal(s) => Some(s), + _ => None, + }, + MpsToken::Literal("/path/to/music/folder".into()), + tokens, + )?); + if tokens.len() > 1 && tokens[0].is_comma() { + assert_token_raw(MpsToken::Comma, tokens)?; + } + } // parse keyword function parameters let ingest = |tokens2: &mut VecDeque| { if tokens2.len() < 3 {