@@ -8,7 +8,7 @@ use crate::ast::{Ty, TyFunc, TyKind};
88use crate :: ir:: decl:: { Decl , DeclKind , Module } ;
99use crate :: ir:: pl:: * ;
1010use crate :: semantic:: resolver:: types;
11- use crate :: semantic:: { NS_GENERIC , NS_PARAM , NS_THAT , NS_THIS } ;
11+ use crate :: semantic:: { NS_GENERIC , NS_LOCAL , NS_PARAM , NS_THAT , NS_THIS } ;
1212use crate :: { Error , Span , WithErrorInfo } ;
1313
1414use super :: Resolver ;
@@ -51,7 +51,7 @@ impl Resolver<'_> {
5151
5252 // push the env
5353 let closure_env = Module :: from_exprs ( closure. env ) ;
54- self . root_mod . module . stack_push ( NS_PARAM , closure_env) ;
54+ self . root_mod . local_mut ( ) . stack_push ( NS_PARAM , closure_env) ;
5555 let closure = Box :: new ( Func {
5656 env : HashMap :: new ( ) ,
5757 ..* closure
@@ -103,7 +103,7 @@ impl Resolver<'_> {
103103 } ;
104104
105105 // pop the env
106- self . root_mod . module . stack_pop ( NS_PARAM ) . unwrap ( ) ;
106+ self . root_mod . local_mut ( ) . stack_pop ( NS_PARAM ) . unwrap ( ) ;
107107
108108 Ok ( Expr { span, ..res } )
109109 }
@@ -114,14 +114,14 @@ impl Resolver<'_> {
114114
115115 let ( func_env, body, return_ty) = env_of_closure ( * closure) ;
116116
117- self . root_mod . module . stack_push ( NS_PARAM , func_env) ;
117+ self . root_mod . local_mut ( ) . stack_push ( NS_PARAM , func_env) ;
118118
119119 // fold again, to resolve inner variables & functions
120120 let body = self . fold_expr ( body) ?;
121121
122122 // remove param decls
123123 log:: debug!( "stack_pop: {:?}" , body. id) ;
124- let func_env = self . root_mod . module . stack_pop ( NS_PARAM ) . unwrap ( ) ;
124+ let func_env = self . root_mod . local_mut ( ) . stack_pop ( NS_PARAM ) . unwrap ( ) ;
125125
126126 Ok ( if let ExprKind :: Func ( mut inner_closure) = body. kind {
127127 // body couldn't been resolved - construct a closure to be evaluated later
@@ -176,7 +176,7 @@ impl Resolver<'_> {
176176 // insert _generic.name declaration
177177 let ident = Ident :: from_path ( vec ! [ NS_GENERIC , generic_param. name. as_str( ) ] ) ;
178178 let decl = Decl :: from ( DeclKind :: Ty ( Ty :: new ( TyKind :: GenericArg ( generic_id) ) ) ) ;
179- self . root_mod . module . insert ( ident, decl) . unwrap ( ) ;
179+ self . root_mod . local_mut ( ) . insert ( ident, decl) . unwrap ( ) ;
180180 }
181181
182182 func. params = func
@@ -191,7 +191,7 @@ impl Resolver<'_> {
191191 . try_collect ( ) ?;
192192 func. return_ty = fold_type_opt ( self , func. return_ty ) ?;
193193
194- self . root_mod . module . names . remove ( NS_GENERIC ) ;
194+ self . root_mod . local_mut ( ) . names . remove ( NS_GENERIC ) ;
195195 Ok ( func)
196196 }
197197
@@ -255,8 +255,8 @@ impl Resolver<'_> {
255255
256256 // resolve relational args
257257 if has_relations {
258- self . root_mod . module . shadow ( NS_THIS ) ;
259- self . root_mod . module . shadow ( NS_THAT ) ;
258+ self . root_mod . local_mut ( ) . shadow ( NS_THIS ) ;
259+ self . root_mod . local_mut ( ) . shadow ( NS_THAT ) ;
260260
261261 for ( pos, ( index, ( param, mut arg) ) ) in relations. into_iter ( ) . with_position ( ) {
262262 let is_last = matches ! ( pos, Position :: Last | Position :: Only ) ;
@@ -276,9 +276,9 @@ impl Resolver<'_> {
276276 if partial_application_position. is_none ( ) {
277277 let frame = arg. lineage . as_ref ( ) . unwrap ( ) ;
278278 if is_last {
279- self . root_mod . module . insert_frame ( frame, NS_THIS ) ;
279+ self . root_mod . local_mut ( ) . insert_frame ( frame, NS_THIS ) ;
280280 } else {
281- self . root_mod . module . insert_frame ( frame, NS_THAT ) ;
281+ self . root_mod . local_mut ( ) . insert_frame ( frame, NS_THAT ) ;
282282 }
283283 }
284284
@@ -300,7 +300,9 @@ impl Resolver<'_> {
300300 // add aliased columns into scope
301301 if let Some ( alias) = field. alias . clone ( ) {
302302 let id = field. id . unwrap ( ) ;
303- self . root_mod . module . insert_frame_col ( NS_THIS , alias, id) ;
303+ self . root_mod
304+ . local_mut ( )
305+ . insert_frame_col ( NS_THIS , alias, id) ;
304306 }
305307 fields_new. push ( field) ;
306308 }
@@ -323,8 +325,8 @@ impl Resolver<'_> {
323325 }
324326
325327 if has_relations {
326- self . root_mod . module . unshadow ( NS_THIS ) ;
327- self . root_mod . module . unshadow ( NS_THAT ) ;
328+ self . root_mod . local_mut ( ) . unshadow ( NS_THIS ) ;
329+ self . root_mod . local_mut ( ) . unshadow ( NS_THAT ) ;
328330 }
329331
330332 Ok ( if let Some ( position) = partial_application_position {
@@ -425,6 +427,7 @@ fn extract_partial_application(mut func: Box<Func>, position: usize) -> Box<Func
425427
426428 let param_name = format ! ( "_partial_{}" , arg. id. unwrap( ) ) ;
427429 let substitute_arg = Expr :: new ( Ident :: from_path ( vec ! [
430+ NS_LOCAL . to_string( ) ,
428431 NS_PARAM . to_string( ) ,
429432 param_name. clone( ) ,
430433 ] ) ) ;
0 commit comments