Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Chriscbr committed Sep 4, 2024
1 parent e494308 commit bc450ec
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/@winglang/wingc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use indexmap::IndexMap;
use jsify::JSifier;

use lifting::LiftVisitor;
use parser::{as_wing_library, parse_wing_project};
use parser::{as_wing_library, is_entrypoint_file, parse_wing_project};
use serde::Serialize;
use serde_json::Value;
use struct_schema::StructSchemaVisitor;
Expand Down
12 changes: 12 additions & 0 deletions packages/@winglang/wingc/src/type_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2138,6 +2138,18 @@ impl<'a> TypeChecker<'a> {
}
}

pub fn add_this(&mut self, env: &mut SymbolEnv) {
let sym = Symbol::global("this");
env
.define(
&sym,
SymbolKind::make_free_variable(sym.clone(), self.types.construct_base_type(), false, Phase::Preflight),
AccessModifier::Private,
StatementIdx::Top,
)
.expect("Failed to add this");
}

pub fn add_builtins(&mut self, scope: &mut Scope) {
let optional_string = self.types.make_option(self.types.string());
self.add_builtin(
Expand Down
8 changes: 4 additions & 4 deletions tests/valid/inflight_closure_as_super_param.test.w
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ let c = new Derived() as "derived";
assert(nodeof(c.f).path.endsWith("derived/in_derived"));
// Make sure the instance created in the super call is scoped to the parent (root)
assert(!nodeof(c.f_base).path.endsWith("derived/in_root"));
let appPath = nodeof(this).path;
assert(nodeof(c.f_base).path == "{appPath}/in_root");
let appPath = nodeof(this).path;
assert(nodeof(c.f_base).path == "{appPath}/in_root");

test "boom!" {
assert(c.h() == "boom!");
test "boom!" {
assert(c.h() == "boom!");
}

0 comments on commit bc450ec

Please sign in to comment.