Browse Source

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

Aleksandr Kuzmenko 5 years ago
parent
commit
67c819eb85
2 changed files with 8 additions and 2 deletions
  1. 1 0
      extra/CHANGES.txt
  2. 7 2
      src/generators/genphp7.ml

+ 1 - 0
extra/CHANGES.txt

@@ -17,6 +17,7 @@
 	js/cpp : fixed catch var naming collision (#9413)
 	interp : fixed throwing `haxe.macro.Error` outside of a macro context (#9390)
 	lua : fixed lua.PairTools.ipairsMap method
+	php : fixed an edge case in String methods generation (#9464)
 
 2020-05-13: 4.1.0
 

+ 7 - 2
src/generators/genphp7.ml

@@ -2207,11 +2207,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
 		*)