瀏覽代碼

don't put Void in result

Simon Krajewski 1 年之前
父節點
當前提交
2d9ba3af21
共有 3 個文件被更改,包括 5 次插入4 次删除
  1. 2 1
      src/context/common.ml
  2. 2 1
      src/coro/coro.ml
  3. 1 2
      src/coro/coroToTexpr.ml

+ 2 - 1
src/context/common.ml

@@ -1221,7 +1221,8 @@ let get_entry_point com =
 	) com.main.main_class
 
 let expand_coro_type basic args ret =
-	let tcontinuation = tfun [ret; t_dynamic] basic.tvoid in
+	let ret_type = if ExtType.is_void (follow ret) then t_dynamic else ret in
+	let tcontinuation = tfun [ret_type; t_dynamic] basic.tvoid in
 	let args = args @ [("_hx_continuation",false,tcontinuation)] in
 	let ret = tfun [t_dynamic; t_dynamic] basic.tvoid in
 	(args,ret)

+ 2 - 1
src/coro/coro.ml

@@ -9,7 +9,8 @@ let fun_to_coro ctx e tf =
 	let v_error = alloc_var VGenerated "_hx_error" t_dynamic p in
 	let cb_root = make_block (Some(e.etype,p)) in
 	ignore(CoroFromTexpr.expr_to_coro ctx (v_result,v_error) cb_root tf.tf_expr);
-	let vcontinuation = alloc_var VGenerated "_hx_continuation" (tfun [tf.tf_type; t_dynamic] ctx.com.basic.tvoid) p in
+	let ret_type = if ExtType.is_void (follow tf.tf_type) then t_dynamic else tf.tf_type in
+	let vcontinuation = alloc_var VGenerated "_hx_continuation" (tfun [ret_type; t_dynamic] ctx.com.basic.tvoid) p in
 	let tf_expr = CoroToTexpr.block_to_texpr_coroutine ctx cb_root vcontinuation v_result v_error e.epos in
 	let tf_args = tf.tf_args @ [(vcontinuation,None)] in
 	let tf_type = tfun [t_dynamic; t_dynamic] ctx.com.basic.tvoid in

+ 1 - 2
src/coro/coroToTexpr.ml

@@ -64,8 +64,7 @@ let block_to_texpr_coroutine ctx bb vcontinuation vresult verror p =
 		let tcoroutine = tfun [t_dynamic; t_dynamic] com.basic.tvoid in
 		let tfun = match follow_with_coro call.cs_fun.etype with
 			| Coro (args, ret) ->
-				let tcontinuation = tfun [ret; t_dynamic] com.basic.tvoid in
-				let args = args @ [("",false,tcontinuation)] in
+				let args,ret = Common.expand_coro_type ctx.com.basic args ret in
 				TFun (args, tcoroutine)
 			| NotCoro _ ->
 				die "Unexpected coroutine type" __LOC__