Explorar o código

Watch out for null returns generated by callbacks

Hugh Sanderson %!s(int64=14) %!d(string=hai) anos
pai
achega
bf9780d78c
Modificáronse 1 ficheiros con 6 adicións e 2 borrados
  1. 6 2
      gencpp.ml

+ 6 - 2
gencpp.ml

@@ -1247,9 +1247,13 @@ and gen_expression ctx retval expression =
 	| TReturn optional_expr ->
 		output "";
 		( match optional_expr with
-		| Some expression ->
+		| Some return_expression when ( (type_string expression.etype)="Void") ->
+			output "return null(";
+         gen_expression ctx true return_expression;
+			output ")";
+		| Some return_expression ->
 			output "return ";
-			gen_expression ctx true expression
+			gen_expression ctx true return_expression
 		| _ -> output "return null()"
 		)