Aleksandr Kuzmenko 5 年 前
コミット
6770badcec
2 ファイル変更6 行追加6 行削除
  1. 1 0
      extra/CHANGES.txt
  2. 5 6
      src/generators/genlua.ml

+ 1 - 0
extra/CHANGES.txt

@@ -3,6 +3,7 @@
 	Bugfixes:
 
 	macro : fixed type intersection syntax in macro reification (#9404)
+	lua : fixed lua code generation without `--main` compilation argument (#9489)
 
 2020-22-05 4.1.1
 

+ 5 - 6
src/generators/genlua.ml

@@ -2081,14 +2081,12 @@ let generate com =
 
     List.iter (generate_enumMeta_fields ctx) com.types;
 
-    match com.main with
-     | None -> ()
-     | Some e ->
+    Option.may (fun e ->
         spr ctx "_G.xpcall(";
         (match e.eexpr with
-         | TCall(e2,[]) ->
+        | TCall(e2,[]) ->
             gen_value ctx e2;
-         | _->
+        | _->
             let fn =
                 {
                     tf_args = [];
@@ -2099,7 +2097,8 @@ let generate com =
             gen_value ctx { e with eexpr = TFunction fn; etype = TFun ([],com.basic.tvoid) }
         );
         spr ctx ", _hx_error)";
-        newline ctx;
+        newline ctx
+    ) com.main;
 
     if anyExposed then
         println ctx "return _hx_exports";