浏览代码

Do not call tmp variable 'result'. Closes https://github.com/HaxeFoundation/hxcpp/issues/192

Hugh 10 年之前
父节点
当前提交
89a6b13b5b
共有 2 个文件被更改,包括 15 次插入5 次删除
  1. 5 5
      gencpp.ml
  2. 10 0
      tests/unit/src/unit/hxcpp_issues/Issue192.hx

+ 5 - 5
gencpp.ml

@@ -3507,16 +3507,16 @@ let generate_class_files common_ctx member_types super_deps constructor_deps cla
       output_cpp (ptr_name ^ " " ^ class_name ^ "::__new(" ^constructor_type_args ^")\n");
 
       let create_result () =
-         output_cpp ("{  " ^ ptr_name ^ " result = new " ^ class_name ^ "();\n");
+         output_cpp ("{  " ^ ptr_name ^ " _result_ = new " ^ class_name ^ "();\n");
          in
       create_result ();
-      output_cpp ("\tresult->__construct(" ^ constructor_args ^ ");\n");
-      output_cpp ("\treturn result;}\n\n");
+      output_cpp ("\t_result_->__construct(" ^ constructor_args ^ ");\n");
+      output_cpp ("\treturn _result_;}\n\n");
 
       output_cpp ("Dynamic " ^ class_name ^ "::__Create(hx::DynamicArray inArgs)\n");
       create_result ();
-      output_cpp ("\tresult->__construct(" ^ (array_arg_list constructor_var_list) ^ ");\n");
-      output_cpp ("\treturn result;}\n\n");
+      output_cpp ("\t_result_->__construct(" ^ (array_arg_list constructor_var_list) ^ ");\n");
+      output_cpp ("\treturn _result_;}\n\n");
       if ( (List.length implemented) > 0 ) then begin
          output_cpp ("hx::Object *" ^ class_name ^ "::__ToInterface(const hx::type_info &inType) {\n");
          List.iter (fun interface_name ->

+ 10 - 0
tests/unit/src/unit/hxcpp_issues/Issue192.hx

@@ -0,0 +1,10 @@
+package unit.hxcpp_issues;
+
+class ConstuctorWithArgCalledResult {
+   public function new(result:Int) { }
+}
+
+class Issue192 extends Test {
+	function test() new ConstuctorWithArgCalledResult(1);
+}
+