From fc4e19540659eca83e52116e36a49cefa0d87902 Mon Sep 17 00:00:00 2001 From: yoav-steinberg Date: Mon, 14 Aug 2023 09:29:26 +0300 Subject: [PATCH] fix(compiler): remove some dead capturing code (#3799) This is a tiny fix removing dead capturing code. For some reason there's code that tries to capture the parent class of a inflight class in the irrelevant case that we're inside an inflight context. In this case the code is dead because an inflight class within an inflight class generates inlined code. The PR also adds some coloring improvements to the env printing I used to debug this and fixed a comment related to parent class capturing. ## Checklist - [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [ ] Tests added (always) - [ ] Docs updated (only required for features) - [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*. --- libs/wingc/src/ast.rs | 2 +- libs/wingc/src/lifting.rs | 10 ---------- libs/wingc/src/type_check/symbol_env.rs | 4 ++-- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/libs/wingc/src/ast.rs b/libs/wingc/src/ast.rs index f10be4c350d..5b4b0690f0f 100644 --- a/libs/wingc/src/ast.rs +++ b/libs/wingc/src/ast.rs @@ -599,7 +599,7 @@ impl Expr { Self { id, kind, span } } - /// Returns true if the expression is a reference to a type. + /// Returns the user defined type if the expression is a reference to a type. pub fn as_type_reference(&self) -> Option<&UserDefinedType> { match &self.kind { ExprKind::Reference(Reference::TypeReference(t)) => Some(t), diff --git a/libs/wingc/src/lifting.rs b/libs/wingc/src/lifting.rs index 65e3a78e734..69cfce91b93 100644 --- a/libs/wingc/src/lifting.rs +++ b/libs/wingc/src/lifting.rs @@ -285,16 +285,6 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { None }; - if self.ctx.current_phase() == Phase::Inflight { - if let Some(parent) = &node.parent { - if self.should_capture_expr(parent) { - let mut lifts = self.lifts_stack.pop().unwrap(); - lifts.capture(&parent.id, &self.jsify_expr(&parent, Phase::Inflight)); - self.lifts_stack.push(lifts); - } - } - } - let udt = UserDefinedType { root: node.name.clone(), fields: vec![], diff --git a/libs/wingc/src/type_check/symbol_env.rs b/libs/wingc/src/type_check/symbol_env.rs index 6ddf6c57791..ccdeb9aeb45 100644 --- a/libs/wingc/src/type_check/symbol_env.rs +++ b/libs/wingc/src/type_check/symbol_env.rs @@ -38,7 +38,7 @@ impl Display for SymbolEnv { let mut level = 0; let mut env = self; loop { - write!(f, "level {}: {{ ", level)?; + write!(f, "level {}: {{ ", level.to_string().bold())?; let mut items = vec![]; for (name, (_, kind)) in &env.symbol_map { let repr = match kind { @@ -46,7 +46,7 @@ impl Display for SymbolEnv { SymbolKind::Variable(v) => format!("{}", v.type_).blue(), SymbolKind::Namespace(ns) => format!("{} [namespace]", ns.name).green(), }; - items.push(format!("{} => {}", name, repr)); + items.push(format!("{} => {}", name.bold(), repr)); } write!(f, "{} }}", items.join(", "))?;