Browse Source

Lua : don't generate TLocal expressions in gen_block_element

Once again, I'm finding a case where Haxe will generate a variable as
the complete entire in a block. E.g., a plain "x" variable expression:

```
var x = 4;
x;
```

Lua can't handle that, and since this expression has no side effect we
can just avoid generating it in the first place.
Justin Donaldson 10 năm trước cách đây
mục cha
commit
ccaeed5e59
1 tập tin đã thay đổi với 1 bổ sung1 xóa
  1. 1 1
      genlua.ml

+ 1 - 1
genlua.ml

@@ -727,7 +727,7 @@ and gen_block_element ?(after=false) ctx e =
 		spr ctx "(function() return ";
 		gen_tbinop ctx op e1 e2;
 		spr ctx " end)()";
-	| TConst c -> ()
+	| TConst _ | TLocal _ -> ()
 	| TBlock el ->
 		List.iter (gen_block_element ~after ctx) el
 	| TCall ({ eexpr = TLocal { v_name = "__feature__" } }, { eexpr = TConst (TString f) } :: eif :: eelse) ->