浏览代码

respect `with_type` in `handle_display`

Simon Krajewski 9 年之前
父节点
当前提交
d14b6746da
共有 3 个文件被更改,包括 7 次插入3 次删除
  1. 1 1
      src/typing/matcher.ml
  2. 5 1
      src/typing/typer.ml
  3. 1 1
      tests/misc/projects/Issue5118/compile.hxml.stderr

+ 1 - 1
src/typing/matcher.ml

@@ -402,7 +402,7 @@ module Pattern = struct
 				let pat = make pctx e1.etype e2 in
 				PatExtractor(v,e1,pat)
 			| EDisplay(e,call) ->
-				Typer.handle_display ctx e call (WithType t) p;
+				let _ = Typer.handle_display ctx e call (WithType t) p in
 				fail()
 			| _ ->
 				fail()

+ 5 - 1
src/typing/typer.ml

@@ -3747,7 +3747,7 @@ and handle_display ctx e_ast iscall with_type p =
 		tl
 	in
 	let e = try
-		type_expr ctx e_ast Value
+		type_expr ctx e_ast with_type
 	with Error (Unknown_ident n,_) when not iscall ->
 		raise (Parser.TypePath ([n],None,false))
 	| Error (Unknown_ident "trace",_) ->
@@ -3759,6 +3759,10 @@ and handle_display ctx e_ast iscall with_type p =
 			raise err
 		end
 	in
+	let e = match with_type with
+		| WithType t -> (try Codegen.AbstractCast.cast_or_unify_raise ctx t e e.epos with Error (Unify l,p) -> e)
+		| _ -> e
+	in
 	ctx.in_display <- old;
 	let handle_field cf =
 		if ctx.com.display = DMPosition then

+ 1 - 1
tests/misc/projects/Issue5118/compile.hxml.stderr

@@ -1,3 +1,3 @@
 <type>
-haxe.ds.Option&lt;Unknown&lt;0&gt;&gt;
+haxe.ds.Option&lt;Int&gt;
 </type>