Skip to content

Commit

Permalink
Update current scope when computing closure usage. (#6162)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyalesokhin-starkware authored Aug 7, 2024
1 parent 209c183 commit dd86a0e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions crates/cairo-lang-semantic/src/usage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
6 changes: 5 additions & 1 deletion crates/cairo-lang-semantic/src/usage/test_data/usage
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ test_function_usage
//! > function
fn foo(a: u32) {
|b: u32| {
a + b
|| a + b;
};
}

Expand All @@ -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:
Expand Down

0 comments on commit dd86a0e

Please sign in to comment.