From b82a4869d572b12b9ca9b7bf43551600b1bafbed Mon Sep 17 00:00:00 2001 From: JT Date: Sat, 31 Jul 2021 16:25:26 +1200 Subject: [PATCH] Add test --- src/parser.rs | 6 ++++++ src/tests.rs | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/parser.rs b/src/parser.rs index 6913328878..1ed0835c6b 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -2101,6 +2101,12 @@ impl<'a> ParserWorkingSet<'a> { .expect("internal error: expected def name"); self.enter_scope(); + // FIXME: because parse_signature will update the scope with the variables it sees + // we end up parsing the signature twice per def. The first time is during the predecl + // so that we can see the types that are part of the signature, which we need for parsing. + // The second time is when we actually parse the body itself. + // We can't reuse the first time because the variables that are created during parse_signature + // are lost when we exit the scope below. let (sig, ..) = self.parse_signature(spans[2]); let mut signature = sig .as_signature() diff --git a/src/tests.rs b/src/tests.rs index 22028ce3e2..665930f049 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -118,3 +118,8 @@ fn simple_var_closing() -> TestResult { fn predecl_check() -> TestResult { run_test("def bob [] { sam }; def sam [] { 3 }; bob", "3") } + +#[test] +fn def_with_no_dollar() -> TestResult { + run_test("def bob [x] { $x + 3 }; bob 4", "7") +}