diff --git a/mps-interpreter/src/lang/iter_block.rs b/mps-interpreter/src/lang/iter_block.rs index f957956..f9ac4ae 100644 --- a/mps-interpreter/src/lang/iter_block.rs +++ b/mps-interpreter/src/lang/iter_block.rs @@ -260,7 +260,7 @@ impl MpsItemBlockFactory { impl BoxedMpsOpFactory for MpsItemBlockFactory { fn is_op_boxed(&self, tokens: &VecDeque) -> bool { - tokens[tokens.len() - 1].is_close_curly() + find_last_open_curly(tokens).is_some() } fn build_op_boxed( @@ -347,7 +347,12 @@ fn find_last_open_curly(tokens: &VecDeque) -> Option { if bracket_depth == 0 && curly_found { return Some(i + 1); } - } + }, + MpsToken::OpenBracket | MpsToken::CloseBracket => { + if bracket_depth == 0 { + return None; + } + }, _ => {} } if token.is_open_curly() { diff --git a/mps-interpreter/tests/single_line.rs b/mps-interpreter/tests/single_line.rs index 54b713c..a7fa2c8 100644 --- a/mps-interpreter/tests/single_line.rs +++ b/mps-interpreter/tests/single_line.rs @@ -677,7 +677,7 @@ fn execute_compareitemop_line() -> Result<(), Box> { #[test] fn execute_computeitemop_line() -> Result<(), Box> { execute_single_line( - "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).(artist? like `Bruno`).{ + "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).{ let count = 1, item.track = count, item.title = ~`Song #{track}` item, @@ -693,6 +693,25 @@ fn execute_computeitemop_line() -> Result<(), Box> { ) } +#[test] +fn execute_complexitemop_line() -> Result<(), Box> { + execute_single_line( + "files(`~/Music/MusicFlac/Bruno Mars/24K Magic/`).().{ + let count = 1, + item.track = count, + item.title = ~`Song #{track}` item, + if count > 5 { + item.filename = `¯\\\\_(ツ)_/¯` + } else { + item.filename = `/shrug`, + }, + count = count + 1, +}.()", + false, + true, + ) +} + #[test] fn execute_constructitemop_line() -> Result<(), Box> { execute_single_line(