瀏覽代碼

[display] several error handling fixes

Jens Fischer 6 年之前
父節點
當前提交
ca27cf0ebe
共有 2 個文件被更改,包括 5 次插入4 次删除
  1. 1 0
      src/typing/forLoop.ml
  2. 4 4
      src/typing/typerDisplay.ml

+ 1 - 0
src/typing/forLoop.ml

@@ -58,6 +58,7 @@ module IterationKind = struct
 				unify_raise ctx acc.etype t acc.epos;
 				acc
 			with Error (Unify(l),p) ->
+				if resume then raise Not_found;
 				display_error ctx "Field iterator has an invalid type" acc.epos;
 				display_error ctx (error_msg (Unify l)) p;
 				mk (TConst TNull) t_dynamic p

+ 4 - 4
src/typing/typerDisplay.ml

@@ -380,12 +380,12 @@ and display_expr ctx e_ast e dk with_type p =
 	| DMDefault | DMNone | DMModuleSymbols _ | DMDiagnostics _ | DMStatistics ->
 		let fields = DisplayFields.collect ctx e_ast e dk with_type p in
 		let item = completion_item_of_expr ctx e in
-		let iterator =
+		let iterator = try
 			let it = (ForLoop.IterationKind.of_texpr ~resume:true ctx e (fun _ -> false) e.epos) in
-			try match follow it.it_type with
+			match follow it.it_type with
 				| TDynamic _ ->  None
 				| t -> Some t
-			with _ ->
+			with Not_found ->
 				None
 		in
 		let keyValueIterator =
@@ -398,7 +398,7 @@ and display_expr ctx e_ast e dk with_type p =
 						Some (key.cf_type,value.cf_type)
 					| _ ->
 						None
-			end with _ ->
+			end with Not_found ->
 				None
 		in
 		raise_fields fields (CRField(item,e.epos,iterator,keyValueIterator)) None