Explorar o código

reset `in_loop` in closures (closes #3812)

Simon Krajewski %!s(int64=10) %!d(string=hai) anos
pai
achega
cebe8db374
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  1. 4 2
      typer.ml

+ 4 - 2
typer.ml

@@ -3346,8 +3346,9 @@ and type_expr ctx (e,p) (with_type:with_type) =
 			if with_type <> NoValue then error "Type parameters are not supported for rvalue functions" p
 		end;
 		List.iter (fun tp -> if tp.tp_constraints <> [] then display_error ctx "Type parameter constraints are not supported for local functions" p) f.f_params;
-		let old = ctx.type_params in
+		let old_tp,old_in_loop = ctx.type_params,ctx.in_loop in
 		ctx.type_params <- params @ ctx.type_params;
+		ctx.in_loop <- false;
 		let rt = Typeload.load_type_opt ctx p f.f_type in
 		let args = List.map (fun (s,opt,t,c) ->
 			let t = Typeload.load_type_opt ctx p t in
@@ -3397,7 +3398,8 @@ and type_expr ctx (e,p) (with_type:with_type) =
 			| _ -> FunMemberClassLocal
 		in
 		let e , fargs = Typeload.type_function ctx args rt curfun f false p in
-		ctx.type_params <- old;
+		ctx.type_params <- old_tp;
+		ctx.in_loop <- old_in_loop;
 		let f = {
 			tf_args = fargs;
 			tf_type = rt;