Browse Source

Inline assigment moved to gen_value + gen_return fix

Fixes Issue4076 line 7
Fixes BytesInput line 86
PeyTy 10 years ago
parent
commit
2505a750d8
1 changed files with 9 additions and 10 deletions
  1. 9 10
      genlua.ml

+ 9 - 10
genlua.ml

@@ -846,6 +846,12 @@ and gen_value ctx e =
 		)
 	in
 	match e.eexpr with
+	| TBinop((OpAssignOp(_)|OpAssign),e1,e2) ->
+		spr ctx "((function()";
+		gen_expr ctx e;
+		spr ctx ";return ";
+		gen_expr ctx e1;
+		spr ctx ";end)())";
 	| TConst _
 	| TLocal _
 	| TArray _
@@ -1012,16 +1018,9 @@ and gen_return ctx e eo =
 	    spr ctx "do return end"
     | Some e ->
 	    spr ctx "do return ";
-	    (match e.eexpr with
-		| TBinop(OpAssign, e1, e2) ->
-			spr ctx "(function() ";
-			gen_value ctx e;
-			spr ctx " return ";
-			gen_value ctx e1;
-			spr ctx " end)()";
-		| _ -> gen_value ctx e;
-	    );
-	    spr ctx " end")
+	    gen_value ctx e;
+	    spr ctx " end"
+	)
 
 and gen_iife_assign ctx f =
     spr ctx "(function() return ";