]> git.lizzy.rs Git - metalua.git/commitdiff
fixed bug in `Stat{ } scoping by walk.id
authorFabien Fleutot <fabien@macfabien.local>
Sun, 27 Jan 2008 19:57:06 +0000 (20:57 +0100)
committerFabien Fleutot <fabien@macfabien.local>
Sun, 27 Jan 2008 19:57:06 +0000 (20:57 +0100)
src/lib/walk/id.mlua

index db3f1250143d67eedcaaae40b77bc4085fb89ea3..3cf36037c4c4bfafd9e1b42d49978523d29be94d 100644 (file)
@@ -97,7 +97,18 @@ local function _walk_id (kind, supercfg, ast, ...)
          end
          if r then return r end
       | `Function{ params, _ } -> scope:push (params, x)
-      | _                      -> -- pass
+      | `Stat{ block, expr }   -> 
+         -------------------------------------------------------------
+         -- 'expr' is in the scope of 'block': create the scope and
+         -- walk the block 'manually', then prevent automatic walk
+         -- by returning 'break'.
+         -------------------------------------------------------------
+         scope:push()
+         for stat in values (block) do walk.stat(cfg, stat, x, ...) end 
+         walk.expr(cfg, expr, x, ...)
+         scope:pop()
+         return 'break'
+      | _ -> -- pass
       end
 
    end
@@ -124,15 +135,15 @@ local function _walk_id (kind, supercfg, ast, ...)
       | `Forin{ vars, ... }    -> scope:push (vars,  x)
       | `Fornum{ var, ... }    -> scope:push ({var}, x)
       | `Localrec{ vars, ... } -> scope:add  (vars,  x)
-      | `Repeat{ block, cond } -> 
+      | `Repeat{ block, expr } ->
          -------------------------------------------------------------
-         -- 'cond' is in the scope of 'block': create the scope and
+         -- 'expr' is in the scope of 'block': create the scope and
          -- walk the block 'manually', then prevent automatic walk
          -- by returning 'break'.
          -------------------------------------------------------------
-         scope:push()
-         for s in values (block) do walk.stat(cfg, s, x, ...) end 
-         walk.expr(cfg, cond, x, ...)
+         scope:push() 
+         for stat in values (block) do walk.stat(cfg, stat, x, ...) end 
+         walk.expr(cfg, expr, x, ...)
          scope:pop()
          return 'break'
       | _ -> -- pass