From c9d422335f848e66f4936a9489ad2d5692ec7165 Mon Sep 17 00:00:00 2001 From: Folkert Date: Sat, 23 Apr 2022 22:15:09 +0200 Subject: [PATCH] inline function --- compiler/can/src/def.rs | 5 +++++ compiler/can/src/env.rs | 4 ---- compiler/can/src/expr.rs | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/compiler/can/src/def.rs b/compiler/can/src/def.rs index 2a0c4341c9..b60784cd87 100644 --- a/compiler/can/src/def.rs +++ b/compiler/can/src/def.rs @@ -1180,8 +1180,13 @@ fn add_annotation_aliases( // See 3d5a2560057d7f25813112dfa5309956c0f9e6a9 and its // parent commit for the bug this fixed! enum DefReferences { + /// A value may not reference itself Value(References), + + /// If the def is a function, different rules apply (it can call itself) Function(References), + + /// An annotation without a body references no other defs AnnotationWithoutBody, } diff --git a/compiler/can/src/env.rs b/compiler/can/src/env.rs index 8c3f3fb8b1..b07cfe0a77 100644 --- a/compiler/can/src/env.rs +++ b/compiler/can/src/env.rs @@ -182,8 +182,4 @@ impl<'a> Env<'a> { pub fn problem(&mut self, problem: Problem) { self.problems.push(problem) } - - pub fn register_closure(&mut self, symbol: Symbol, references: References) { - self.closures.insert(symbol, references); - } } diff --git a/compiler/can/src/expr.rs b/compiler/can/src/expr.rs index 2dade79cd6..a589b6ca8a 100644 --- a/compiler/can/src/expr.rs +++ b/compiler/can/src/expr.rs @@ -699,7 +699,9 @@ pub fn canonicalize_expr<'a>( } } - env.register_closure(symbol, output.references.clone()); + // store the references of this function in the Env. This information is used + // when we canonicalize a surrounding def (if it exists) + env.closures.insert(symbol, output.references.clone()); let mut captured_symbols: Vec<_> = captured_symbols .into_iter()