Просмотр исходного кода

[php] more descriptive error upon a failure on string method call (#9464)

Aleksandr Kuzmenko 5 лет назад
Родитель
Сommit
47c6d8c4c6
1 измененных файлов с 7 добавлено и 2 удалено
  1. 7 2
      src/generators/genphp7.ml

+ 7 - 2
src/generators/genphp7.ml

@@ -2210,11 +2210,16 @@ class code_writer (ctx:php_generator_context) hx_type_path php_name =
 		*)
 		method write_expr_call_string expr access args =
 			match access with
-				| FInstance (_, _, ({ cf_kind = Method _ } as field)) ->
+				| FInstance (_, _, ({ cf_kind = Method _ } as field))
+				| FClosure (_, ({ cf_kind = Method _ } as field)) ->
 					self#write ((self#use hxstring_type_path) ^ "::" ^ (field_name field) ^ "(");
 					write_args self#write self#write_expr (expr :: args);
 					self#write ")"
-				| _ -> fail self#pos __LOC__
+				| _ ->
+					let msg =
+						"Unexpected field access " ^ (s_field_access (s_type (print_context())) access)
+					in
+					fail ~msg self#pos __LOC__
 		(**
 			Writes FStatic field access for methods to output buffer
 		*)