From dd86a0eb2707d0067939e5051e04b25d93f515f3 Mon Sep 17 00:00:00 2001 From: ilyalesokhin-starkware Date: Wed, 7 Aug 2024 16:32:32 +0300 Subject: [PATCH] Update current scope when computing closure usage. (#6162) --- crates/cairo-lang-semantic/src/usage/mod.rs | 1 + crates/cairo-lang-semantic/src/usage/test_data/usage | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/cairo-lang-semantic/src/usage/mod.rs b/crates/cairo-lang-semantic/src/usage/mod.rs index 328d8477130..61f70f46fb0 100644 --- a/crates/cairo-lang-semantic/src/usage/mod.rs +++ b/crates/cairo-lang-semantic/src/usage/mod.rs @@ -290,6 +290,7 @@ impl Usages { usage.introductions.extend(expr.param_ids.iter().map(|id| VarId::Param(*id))); self.handle_expr(arenas, expr.body, &mut usage); usage.finalize_as_scope(); + current.add_usage_and_changes(&usage); self.usages.insert(expr_id, usage); } Expr::FunctionCall(expr) => { diff --git a/crates/cairo-lang-semantic/src/usage/test_data/usage b/crates/cairo-lang-semantic/src/usage/test_data/usage index 10ee69beb69..a5870e36c17 100644 --- a/crates/cairo-lang-semantic/src/usage/test_data/usage +++ b/crates/cairo-lang-semantic/src/usage/test_data/usage @@ -125,7 +125,7 @@ test_function_usage //! > function fn foo(a: u32) { |b: u32| { - a + b + || a + b; }; } @@ -137,6 +137,10 @@ foo //! > semantic_diagnostics //! > usage +Closure 2:9: + Usage: ParamId(test::a), ParamId(test::b), + Changes: + Snapshot_Usage: Closure 1:4: Usage: ParamId(test::a), Changes: