Browse Source

add abstract type to the error message about missing @:arrayAccess methods

Aleksandr Kuzmenko 5 years ago
parent
commit
f3e3f2257b

+ 5 - 3
src/context/abstractCast.ml

@@ -153,11 +153,13 @@ let find_array_access_raise ctx a pl e1 e2o p =
 
 
 let find_array_access ctx a tl e1 e2o p =
 let find_array_access ctx a tl e1 e2o p =
 	try find_array_access_raise ctx a tl e1 e2o p
 	try find_array_access_raise ctx a tl e1 e2o p
-	with Not_found -> match e2o with
+	with Not_found ->
+		let s_type = s_type (print_context()) in
+		match e2o with
 		| None ->
 		| None ->
-			error (Printf.sprintf "No @:arrayAccess function accepts argument of %s" (s_type (print_context()) e1.etype)) p
+			error (Printf.sprintf "No @:arrayAccess function for %s accepts argument of %s" (s_type (TAbstract(a,tl))) (s_type e1.etype)) p
 		| Some e2 ->
 		| Some e2 ->
-			error (Printf.sprintf "No @:arrayAccess function accepts arguments of %s and %s" (s_type (print_context()) e1.etype) (s_type (print_context()) e2.etype)) p
+			error (Printf.sprintf "No @:arrayAccess function for %s accepts arguments of %s and %s" (s_type (TAbstract(a,tl))) (s_type e1.etype) (s_type e2.etype)) p
 
 
 let find_multitype_specialization com a pl p =
 let find_multitype_specialization com a pl p =
 	let m = mk_mono() in
 	let m = mk_mono() in

+ 1 - 1
tests/misc/projects/Issue9347/compile-fail.hxml.stderr

@@ -1 +1 @@
-Main.hx:5: characters 3-22 : No @:arrayAccess function accepts argument of String
+Main.hx:5: characters 3-22 : No @:arrayAccess function for A2<Main> accepts argument of String