Browse Source

[typer] fix error position on structure fields

closes #6950
Simon Krajewski 7 years ago
parent
commit
eda15465ab

+ 1 - 1
src/typing/typer.ml

@@ -2829,7 +2829,7 @@ and type_object_decl ctx fl with_type p =
 						cf.cf_type
 						cf.cf_type
 				in
 				in
 				let e = type_expr ctx e (WithType t) in
 				let e = type_expr ctx e (WithType t) in
-				let e = AbstractCast.cast_or_unify ctx t e p in
+				let e = AbstractCast.cast_or_unify ctx t e e.epos in
 				(try type_eq EqStrict e.etype t; e with Unify_error _ -> mk (TCast (e,None)) t e.epos)
 				(try type_eq EqStrict e.etype t; e with Unify_error _ -> mk (TCast (e,None)) t e.epos)
 			with Not_found ->
 			with Not_found ->
 				if is_valid then
 				if is_valid then

+ 11 - 0
tests/misc/projects/Issue6950/Main.hx

@@ -0,0 +1,11 @@
+typedef MyTypedef = {
+	b : Bool,
+}
+
+class Main {
+	static public function main() {
+		var t:MyTypedef = {
+			b: 1,
+		}
+	}
+}

+ 2 - 0
tests/misc/projects/Issue6950/compile-fail.hxml

@@ -0,0 +1,2 @@
+-main Main
+--interp

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

@@ -0,0 +1 @@
+Main.hx:8: characters 7-8 : Int should be Bool