소스 검색

[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