소스 검색

Watch out for null returns generated by callbacks

Hugh Sanderson 14 년 전
부모
커밋
bf9780d78c
1개의 변경된 파일6개의 추가작업 그리고 2개의 파일을 삭제
  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()"
 		)