From 9747374e8aa4639abc48833421c1a22358157ca6 Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 2 Mar 2018 22:40:12 -0800 Subject: [PATCH] Fix bug in delimited macro Had to do with bad strictness testing. --- src/schala_lang/parsing.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/schala_lang/parsing.rs b/src/schala_lang/parsing.rs index b59b0c0..b5b713d 100644 --- a/src/schala_lang/parsing.rs +++ b/src/schala_lang/parsing.rs @@ -305,7 +305,8 @@ macro_rules! delimited { acc.push($self.$parse_fn()?); match $self.peek() { $( $delim )|* => { $self.next(); continue }, - _ => break + _ if $strictness => break, + _ => continue, }; } expect!($self, $end, $end_str); @@ -986,6 +987,26 @@ mod parse_tests { parse_test!("fn a(x) {\n x() }", AST(vec![Declaration( FuncDecl(Signature { name: rc!(a), params: vec![(rc!(x),None)], type_anno: None }, vec![exprstatement!(Call { f: bx!(ex!(val!("x"))), arguments: vec![] })]))])); + + let multiline = r#" +fn a(x) { + x() +} +"#; + parse_test!(multiline, AST(vec![Declaration( + FuncDecl(Signature { name: rc!(a), params: vec![(rc!(x),None)], type_anno: None }, + vec![exprstatement!(Call { f: bx!(ex!(val!("x"))), arguments: vec![] })]))])); + let multiline2 = r#" +fn a(x) { + + x() + +} +"#; + parse_test!(multiline2, AST(vec![Declaration( + FuncDecl(Signature { name: rc!(a), params: vec![(rc!(x),None)], type_anno: None }, + vec![exprstatement!(Call { f: bx!(ex!(val!("x"))), arguments: vec![] })]))])); + } #[test]