Parcourir la source

Fixed scope issue in context analysis

Taddeus Kroes il y a 12 ans
Parent
commit
dcce2959c0
1 fichiers modifiés avec 6 ajouts et 7 suppressions
  1. 6 7
      phases/context_analysis.ml

+ 6 - 7
phases/context_analysis.ml

@@ -78,7 +78,7 @@ let rec analyse scope depth args node =
         | FunCall (name, args, loc) ->
             let (decl, dec_depth) = check_in_scope (Funcname name) node scope in
             let node = FunCall (name, transform_all collect args, loc) in
-            FunUse (node, ctypeof decl, depth - dec_depth)
+            FunUse (node, decl, depth - dec_depth)
 
         (* Assign statements are wrapped in VarLet nodes, which stores the type
          * and depth of the assigned variable are *)
@@ -104,8 +104,10 @@ let rec analyse scope depth args node =
         match node with
         (* Increase nesting level when entering function *)
         | FunDef (export, ret_type, name, params, body, loc) ->
-            let params = List.map (traverse scope depth) params in
-            let body = analyse scope depth args body in
+            let (vars, funs) = scope in
+            let local_scope = (Hashtbl.copy vars, Hashtbl.copy funs) in
+            let params = List.map (traverse local_scope (depth + 1)) params in
+            let body = analyse local_scope (depth + 1) args body in
             FunDef (export, ret_type, name, params, body, loc)
 
         | Param (ArrayDec (_, dims), name, _) as node ->
@@ -148,10 +150,7 @@ let rec analyse scope depth args node =
     print_scope ();
     prerr_endline "\ntraversing";*)
 
-    let (vars, funs) = scope in
-    let local_scope = (Hashtbl.copy vars, Hashtbl.copy funs) in
-
-    let node = traverse local_scope (depth + 1) node in
+    let node = traverse scope depth node in
     (*prerr_endline "traversed";
     print_scope ();
     prerr_endline "";*)