From e4c5bdc4866a17666206b9544a8b84edc2fa278a Mon Sep 17 00:00:00 2001 From: Bernardo Uriarte Date: Sat, 7 May 2022 19:44:44 +0200 Subject: [PATCH] fix panic validating `print((1))` --- components/dada-validate/src/validate/validator.rs | 6 +++++- dada_tests/parser/parenthesized_expr.dada | 1 + dada_tests/parser/parenthesized_expr/stdout.ref | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/components/dada-validate/src/validate/validator.rs b/components/dada-validate/src/validate/validator.rs index 1cdad047..5bfb2327 100644 --- a/components/dada-validate/src/validate/validator.rs +++ b/components/dada-validate/src/validate/validator.rs @@ -398,7 +398,11 @@ impl<'me> Validator<'me> { } syntax::ExprData::Parenthesized(parenthesized_expr) => { - self.validate_expr_in_mode(*parenthesized_expr, mode) + let data = self + .validate_expr_in_mode(*parenthesized_expr, mode) + .data(self.tables) + .clone(); + self.add(data, expr) } syntax::ExprData::Tuple(element_exprs) => { diff --git a/dada_tests/parser/parenthesized_expr.dada b/dada_tests/parser/parenthesized_expr.dada index b1cfa7ad..ff606124 100644 --- a/dada_tests/parser/parenthesized_expr.dada +++ b/dada_tests/parser/parenthesized_expr.dada @@ -3,4 +3,5 @@ async fn main() { print(x).await #! OUTPUT 2 x = (1) print(x).await #! OUTPUT 1 + print((3)).await #! OUTPUT 3 } \ No newline at end of file diff --git a/dada_tests/parser/parenthesized_expr/stdout.ref b/dada_tests/parser/parenthesized_expr/stdout.ref index 5f1d0ece..b52e52d0 100644 --- a/dada_tests/parser/parenthesized_expr/stdout.ref +++ b/dada_tests/parser/parenthesized_expr/stdout.ref @@ -1,2 +1,3 @@ 2 1 +3