فهرست منبع

clean up tvar handling

Simon Krajewski 7 سال پیش
والد
کامیت
e926671366

+ 3 - 5
src/context/display/diagnostics.ml

@@ -35,7 +35,7 @@ let find_unused_variables com e =
 	let vars = Hashtbl.create 0 in
 	let pmin_map = Hashtbl.create 0 in
 	let rec loop e = match e.eexpr with
-		| TVar(v,eo) when Meta.has Meta.UserVariable v.v_meta ->
+		| TVar({v_kind = VUser _} as v,eo) ->
 			Hashtbl.add pmin_map e.epos.pmin v;
 			let p = match eo with
 				| None -> e.epos
@@ -44,7 +44,7 @@ let find_unused_variables com e =
 					{ e.epos with pmax = e1.epos.pmin }
 			in
 			Hashtbl.replace vars v.v_id (v,p);
-		| TLocal v when Meta.has Meta.UserVariable v.v_meta ->
+		| TLocal ({v_kind = VUser _} as v) ->
 			Hashtbl.remove vars v.v_id;
 		| _ ->
 			Type.iter loop e
@@ -80,9 +80,7 @@ let check_other_things com e =
 		| TMeta((Meta.Extern,_,_),_) ->
 			(* This is so something like `[inlineFunc()]` is not reported. *)
 			had_effect := true;
-		| TLocal v when not (Meta.has Meta.UserVariable v.v_meta) ->
-			()
-		| TConst _ | TLocal _ | TTypeExpr _ | TFunction _ | TIdent _ when not in_value ->
+		| TConst _ | TLocal {v_kind = VUser _} | TTypeExpr _ | TFunction _ | TIdent _ when not in_value ->
 			no_effect e.epos;
 		| TConst _ | TLocal _ | TTypeExpr _ | TEnumParameter _ | TEnumIndex _ | TVar _ | TIdent _ ->
 			()

+ 3 - 7
src/context/typecore.ml

@@ -219,10 +219,8 @@ let add_local ctx k n t p =
 	ctx.locals <- PMap.add n v ctx.locals;
 	v
 
-let add_local_with_origin ctx k n t p origin =
-	let v = add_local ctx k n t p in
-	if ctx.com.display.DisplayMode.dms_kind <> DisplayMode.DMNone then v.v_meta <- (TVarOrigin.encode_in_meta origin) :: v.v_meta;
-	v
+let add_local_with_origin ctx origin n t p =
+	add_local ctx (VUser origin) n t p
 
 let gen_local_prefix = "`"
 
@@ -235,9 +233,7 @@ let gen_local ctx t p =
 		else
 			nv
 	in
-	let v = add_local ctx VGenerated (loop 0) t p in
-	(* v.v_meta <- (Meta.CompilerGenerated,[],null_pos) :: v.v_meta; *)
-	v
+	add_local ctx VGenerated (loop 0) t p
 
 let is_gen_local v =
 	String.unsafe_get v.v_name 0 = String.unsafe_get gen_local_prefix 0

+ 11 - 5
src/core/json/genjson.ml

@@ -270,11 +270,17 @@ and generate_tvar ctx v =
 		"pos",generate_pos ctx v.v_pos;
 		"isInline",jbool (match v.v_extra with Some (_,Some _) -> true | _ -> false);
 	] in
-	let fields = try
-		let origin = TVarOrigin.decode_from_meta v.v_meta in
-		("origin",jint (TVarOrigin.to_int origin)) :: fields
-	with Not_found ->
-		fields
+	let origin_to_int = function
+		| TVOLocalVariable -> 0
+		| TVOArgument -> 1
+		| TVOForVariable -> 2
+		| TVOPatternVariable -> 3
+		| TVOCatchVariable -> 4
+		| TVOLocalFunction -> 5
+	in
+	let fields = match v.v_kind with
+			| VUser origin -> ("origin",jint (origin_to_int origin)) :: fields
+			| _ -> fields
 	in
 	jobject fields
 

+ 0 - 4
src/core/meta.ml

@@ -161,14 +161,12 @@ type strict_meta =
 	| ToString
 	| Transient
 	| TemplatedCall
-	| TVarOrigin
 	| ValueUsed
 	| Volatile
 	| UnifyMinDynamic
 	| Unreflective
 	| Unsafe
 	| Used
-	| UserVariable
 	| Value
 	| Void
 	| Last
@@ -355,7 +353,6 @@ let get_info = function
 	| StructInit -> ":structInit",("Allows one to initialize the class with a structure that matches constructor parameters",[UsedOn TClass])
 	| SuppressWarnings -> ":suppressWarnings",("Adds a SuppressWarnings annotation for the generated Java class",[Platform Java; UsedOn TClass])
 	| TemplatedCall -> ":templatedCall",("Indicates that the first parameter of static call should be treated as a template argument",[Platform Cpp; UsedOn TClassField])
-	| TVarOrigin -> ":haxe.internal.tvar_origin",("Used internally to mark the origin of a variable",[UsedInternally;UsedOn TVariable])
 	| Throws -> ":throws",("Adds a 'throws' declaration to the generated function",[HasParam "Type as String"; Platform Java; UsedOn TClassField])
 	| This -> ":this",("Internally used to pass a 'this' expression to macros",[UsedInternally; UsedOn TExpr])
 	| To -> ":to",("Specifies that the field of the abstract is a cast operation to the type identified in the function",[UsedOn TAbstractField])
@@ -367,7 +364,6 @@ let get_info = function
 	| Unreflective -> ":unreflective",("",[Platform Cpp])
 	| Unsafe -> ":unsafe",("Declares a class, or a method with the C#'s 'unsafe' flag",[Platform Cs; UsedOnEither [TClass;TClassField]])
 	| Used -> ":used",("Internally used by DCE to mark a class or field as used",[UsedInternally])
-	| UserVariable -> ":userVariable",("Internally used to mark variables that come from user code",[UsedInternally])
 	| Value -> ":value",("Used to store default values for fields and function arguments",[UsedOn TClassField])
 	| Void -> ":void",("Use Cpp native 'void' return type",[Platform Cpp])
 	| Last -> assert false

+ 9 - 45
src/core/type.ml

@@ -85,8 +85,16 @@ and tconstant =
 
 and tvar_extra = (type_params * texpr option) option
 
+and tvar_origin =
+	| TVOLocalVariable
+	| TVOArgument
+	| TVOForVariable
+	| TVOPatternVariable
+	| TVOCatchVariable
+	| TVOLocalFunction
+
 and tvar_kind =
-	| VUser
+	| VUser of tvar_origin
 	| VGenerated
 	| VInlined
 	| VInlinedConstructorVariable
@@ -366,50 +374,6 @@ type class_field_scope =
 	| CFSMember
 	| CFSConstructor
 
-module TVarOrigin = struct
-	type t =
-		| TVOLocalVariable
-		| TVOArgument
-		| TVOForVariable
-		| TVOPatternVariable
-		| TVOCatchVariable
-		| TVOLocalFunction
-
-	let to_int = function
-		| TVOLocalVariable -> 0
-		| TVOArgument -> 1
-		| TVOForVariable -> 2
-		| TVOPatternVariable -> 3
-		| TVOCatchVariable -> 4
-		| TVOLocalFunction -> 5
-
-	let to_string = function
-		| TVOArgument -> "Argument"
-		| TVOLocalVariable -> "LocalVariable"
-		| TVOPatternVariable -> "PatternVariable"
-		| TVOLocalFunction -> "LocalFunction"
-		| TVOForVariable -> "ForVariable"
-		| TVOCatchVariable -> "CatchVariable"
-
-	let from_string = function
-		| "Argument" -> TVOArgument
-		| "LocalVariable" -> TVOLocalVariable
-		| "PatternVariable" -> TVOPatternVariable
-		| "LocalFunction" -> TVOLocalFunction
-		| "ForVariable" -> TVOForVariable
-		| "CatchVariable" -> TVOCatchVariable
-		| _ -> raise Not_found
-
-	let encode_in_meta tvo =
-		let name = to_string tvo in
-		(Meta.TVarOrigin,[(EConst(Ident name),null_pos)],null_pos)
-
-	let decode_from_meta meta =
-		match Meta.get Meta.TVarOrigin meta with
-		| _,[(EConst(Ident s),_)],_ -> from_string s
-		| _ -> raise Not_found
-end
-
 (* ======= General utility ======= *)
 
 let alloc_var =

+ 3 - 3
src/filters/jsExceptions.ml

@@ -114,7 +114,7 @@ let init ctx =
 		| TTry (etry, catches) ->
 			let etry = loop vrethrow etry in
 
-			let catchall_name, catchall_kind = match catches with [(v,_)] -> v.v_name, VUser | _ -> "e", VGenerated in
+			let catchall_name, catchall_kind = match catches with [(v,_)] -> v.v_name, (VUser TVOCatchVariable) | _ -> "e", VGenerated in
 			let vcatchall = alloc_var catchall_kind catchall_name t_dynamic e.epos in
 			let ecatchall = make_local vcatchall e.epos in
 			let erethrow = mk (TThrow ecatchall) t_dynamic e.epos in
@@ -126,14 +126,14 @@ let init ctx =
 			let eunwrap = mk (TIf (eInstanceof, eVal, Some (ecatchall))) t_dynamic e.epos in
 
 			let vunwrapped = alloc_var catchall_kind catchall_name t_dynamic e.epos in
-			vunwrapped.v_meta <- (Meta.CompilerGenerated,[],Globals.null_pos) :: vunwrapped.v_meta;
+			vunwrapped.v_kind <- VGenerated;
 			let eunwrapped = make_local vunwrapped e.epos in
 
 			let ecatch = List.fold_left (fun acc (v,ecatch) ->
 				let ecatch = loop (Some ecatchall) ecatch in
 
 				(* it's not really compiler-generated, but it kind of is, since it was used as catch identifier and we add a TVar for it *)
-				v.v_meta <- (Meta.CompilerGenerated,[],Globals.null_pos) :: v.v_meta;
+				v.v_kind <- VGenerated;
 
 				match follow v.v_type with
 				| TDynamic _ ->

+ 1 - 1
src/generators/gencpp.ml

@@ -2191,7 +2191,7 @@ let cpp_var_debug_name_of v =
 
 
 let cpp_no_debug_synbol ctx var =
-   (ctx.ctx_debug_level<=1) || (has_meta_key var.v_meta Meta.CompilerGenerated) ||
+   (ctx.ctx_debug_level<=1) || (match var.v_kind with VUser _ -> false | _ -> true) ||
       match cpp_type_of ctx var.v_type with
       | TCppStar _ | TCppReference _ -> true
       | TCppInst (class_def) when (has_meta_key class_def.cl_meta Meta.StructAccess) -> true

+ 3 - 2
src/generators/genhl.ml

@@ -965,8 +965,9 @@ let real_name v =
 	| "_gthis" -> "this"
 	| name -> name
 
-let is_gen_local ctx v =
-	v.v_kind <> VUser
+let is_gen_local ctx v = match v.v_kind with
+	| VUser _ -> false
+	| _ -> true
 
 let add_assign ctx v =
 	if is_gen_local ctx v then () else

+ 1 - 1
src/generators/genswf9.ml

@@ -2007,7 +2007,7 @@ let generate_field_kind ctx f c stat =
 			) args;
 			let dparams = (match !dparams with None -> None | Some l -> Some (List.rev l)) in
 			Some (HFMethod {
-				hlm_type = end_fun ctx (List.map (fun (a,opt,t) -> alloc_var VUser a t f.cf_pos, (if opt then Some TNull else None)) args) dparams tret;
+				hlm_type = end_fun ctx (List.map (fun (a,opt,t) -> alloc_var (VUser TVOArgument) a t f.cf_pos, (if opt then Some TNull else None)) args) dparams tret;
 				hlm_final = false;
 				hlm_override = false;
 				hlm_kind = snd (method_kind());

+ 1 - 1
src/optimization/analyzer.ml

@@ -638,7 +638,7 @@ module LocalDce = struct
 			Meta.has Meta.Used v.v_meta
 		in
 		let keep v =
-			is_used v || (not (Meta.has Meta.CompilerGenerated v.v_meta) && not ctx.config.local_dce) || is_ref_type v.v_type || v.v_capture || Meta.has Meta.This v.v_meta
+			is_used v || ((match v.v_kind with VUser _ | VInlined -> true | _ -> false) && not ctx.config.local_dce) || is_ref_type v.v_type || v.v_capture || Meta.has Meta.This v.v_meta
 		in
 		let rec use v =
 			if not (is_used v) then begin

+ 1 - 1
src/optimization/analyzerTexpr.ml

@@ -711,7 +711,7 @@ module Fusion = struct
 			let num_uses = state#get_reads v in
 			let num_writes = state#get_writes v in
 			let can_be_used_as_value = can_be_used_as_value com e in
-			let is_compiler_generated = Meta.has Meta.CompilerGenerated v.v_meta in
+			let is_compiler_generated = match v.v_kind with VUser _ | VInlined -> false | _ -> true in
 			let has_type_params = match v.v_extra with Some (tl,_) when tl <> [] -> true | _ -> false in
 			let b = num_uses <= 1 &&
 			        num_writes = 0 &&

+ 0 - 4
src/optimization/analyzerTexprTransformer.ml

@@ -240,10 +240,6 @@ let rec func ctx bb tf t p =
 				| [] -> ctx.temp_var_name
 		in
 		let v = match v with Some v -> v | None -> alloc_var VGenerated (loop e) e.etype e.epos in
-		begin match ctx.com.platform with
-			| Globals.Cpp when sequential && not (Common.defined ctx.com Define.Cppia) -> ()
-			| _ -> v.v_meta <- [Meta.CompilerGenerated,[],e.epos];
-		end;
 		let bb = declare_var_and_assign bb v e e.epos in
 		let e = {e with eexpr = TLocal v} in
 		let e = List.fold_left (fun e f -> f e) e fl in

+ 3 - 3
src/optimization/inline.ml

@@ -47,7 +47,7 @@ let api_inline2 com c field params p =
 			None)
 	| ([],"Std"),"string",[{ eexpr = TIf (_,{ eexpr = TConst (TString _)},Some { eexpr = TConst (TString _) }) } as e] ->
 		Some e
-	| ([],"Std"),"string",[{ eexpr = TLocal v | TField({ eexpr = TLocal v },_) } as ev] when (com.platform = Js || com.platform = Flash) && not (Meta.has Meta.CompilerGenerated v.v_meta) ->
+	| ([],"Std"),"string",[{ eexpr = TLocal v | TField({ eexpr = TLocal v },_) } as ev] when (com.platform = Js || com.platform = Flash) && (match v.v_kind with VUser _ -> true | _ -> false) ->
 		let pos = ev.epos in
 		let stringv() =
 			let to_str = mk (TBinop (Ast.OpAdd, mk (TConst (TString "")) com.basic.tstring pos, ev)) com.basic.tstring pos in
@@ -258,7 +258,7 @@ class inline_state ctx ethis params cf f p = object(self)
 		try
 			Hashtbl.find locals v.v_id
 		with Not_found ->
-			let v' = alloc_var VInlined v.v_name v.v_type v.v_pos in
+			let v' = alloc_var (match v.v_kind with VUser _ -> VInlined | k -> k) v.v_name v.v_type v.v_pos in
 			v'.v_extra <- v.v_extra;
 			let i = {
 				i_var = v;
@@ -330,7 +330,7 @@ class inline_state ctx ethis params cf f p = object(self)
 			let reject () =
 				(* mark the replacement local for the analyzer *)
 				if (i.i_read + i.i_called) <= 1 && not i.i_write then
-					i.i_subst.v_meta <- (Meta.CompilerGenerated,[],p) :: i.i_subst.v_meta;
+					i.i_subst.v_kind <- VGenerated;
 				(i.i_subst,Some e) :: acc
 			in
 			if i.i_abstract_this && i.i_write then begin

+ 5 - 5
src/optimization/inlineConstructors.ml

@@ -229,7 +229,7 @@ let inline_constructors ctx e =
 						begin match e.eexpr with
 						| TConst _ -> loop (vs, decls, e::es) el
 						| _ ->
-							let v = alloc_var VInlined "arg" e.etype e.epos in
+							let v = alloc_var VGenerated "arg" e.etype e.epos in
 							let decle = mk (TVar(v, Some e)) ctx.t.tvoid e.epos in
 							let io_id_start = !current_io_id in
 							ignore(analyze_aliases true decle);
@@ -241,7 +241,7 @@ let inline_constructors ctx e =
 				in
 				let argvs, argvdecls, pl = loop ([],[],[]) pl in
 				let _, cname = c.cl_path in
-				let v = alloc_var VInlined ("inl"^cname) e.etype e.epos in
+				let v = alloc_var VGenerated ("inl"^cname) e.etype e.epos in
 				match Inline.type_inline_ctor ctx c cf tf (mk (TLocal v) (TInst (c,tl)) e.epos) pl e.epos with
 				| Some inlined_expr ->
 					let has_untyped = (Meta.has Meta.HasUntyped cf.cf_meta) in
@@ -273,7 +273,7 @@ let inline_constructors ctx e =
 		| TNew({ cl_constructor = Some ({cf_kind = Method MethInline; cf_expr = Some _} as cf)} as c,_,pl),_ when is_extern_ctor c cf ->
 			error "Extern constructor could not be inlined" e.epos;
 		| TObjectDecl fl, _ when captured && fl <> [] && List.for_all (fun((s,_,_),_) -> Lexer.is_valid_identifier s) fl ->
-			let v = alloc_var VInlined "inlobj" e.etype e.epos in
+			let v = alloc_var VGenerated "inlobj" e.etype e.epos in
 			let ev = mk (TLocal v) v.v_type e.epos in
 			let el = List.map (fun ((s,_,_),e) ->
 				let ef = mk (TField(ev,FDynamic s)) e.etype e.epos in
@@ -290,7 +290,7 @@ let inline_constructors ctx e =
 			Some iv
 		| TArrayDecl el, TInst(_, [elemtype]) when captured ->
 			let len = List.length el in
-			let v = alloc_var VInlined "inlarr" e.etype e.epos in
+			let v = alloc_var VGenerated "inlarr" e.etype e.epos in
 			let ev = mk (TLocal v) v.v_type e.epos in
 			let el = List.mapi (fun i e ->
 				let ef = mk (TArray(ev,(mk (TConst(TInt (Int32.of_int i))) e.etype e.epos))) elemtype e.epos in
@@ -509,7 +509,7 @@ let inline_constructors ctx e =
 		let rec get_pretty_name iv = match iv.iv_kind with
 			| IVKField(io,fname,None) ->
 				begin try
-					let is_user_variable iv = Meta.has Meta.UserVariable iv.iv_var.v_meta in
+					let is_user_variable iv = match iv.iv_var.v_kind with VUser _ | VInlined -> true | _ -> false in
 					let iv = List.find is_user_variable io.io_aliases in
 					(get_pretty_name iv) ^ "_" ^ fname;
 				with Not_found ->

+ 1 - 1
src/typing/forLoop.ml

@@ -329,7 +329,7 @@ let type_for_loop ctx handle_display it e2 p =
 	ctx.in_loop <- true;
 	let e2 = Expr.ensure_block e2 in
 	let iterator = IterationKind.of_texpr ctx e1 (is_cheap_enough ctx e2) p in
-	let i = add_local_with_origin ctx VUser i iterator.it_type pi (TVarOrigin.TVOForVariable) in
+	let i = add_local_with_origin ctx TVOForVariable i iterator.it_type pi in
 	let e2 = type_expr ctx e2 NoValue in
 	begin match dko with
 	| None -> ()

+ 1 - 2
src/typing/matcher.ml

@@ -184,8 +184,7 @@ module Pattern = struct
 				pctx.current_locals <- PMap.add name (v,p) pctx.current_locals;
 				v
 			| _ ->
-				let v = alloc_var VUser name t p in
-				v.v_meta <- (TVarOrigin.encode_in_meta TVarOrigin.TVOPatternVariable) :: v.v_meta;
+				let v = alloc_var (VUser TVOPatternVariable) name t p in
 				pctx.current_locals <- PMap.add name (v,p) pctx.current_locals;
 				ctx.locals <- PMap.add name v ctx.locals;
 				v

+ 2 - 2
src/typing/typeloadFields.ml

@@ -163,7 +163,7 @@ let ensure_struct_init_constructor ctx c ast_fields p =
 				let has_default_expr = field_has_default_expr cf.cf_name in
 				let opt = has_default_expr || (Meta.has Meta.Optional cf.cf_meta) in
 				let t = if opt then ctx.t.tnull cf.cf_type else cf.cf_type in
-				let v = alloc_var VUser cf.cf_name t p in
+				let v = alloc_var VGenerated cf.cf_name t p in
 				let ef = mk (TField(ethis,FInstance(c,params,cf))) t p in
 				let ev = mk (TLocal v) v.v_type p in
 				(* this.field = <constructor_argument> *)
@@ -606,7 +606,7 @@ let check_field_display ctx fctx c cf =
 		let scope, cf = match c.cl_kind with
 			| KAbstractImpl _ ->
 				if Meta.has Meta.Impl cf.cf_meta then
-					(if cf.cf_name = "_new" then 
+					(if cf.cf_name = "_new" then
 						CFSConstructor, {cf with cf_name = "new"}
 					else
 						CFSMember, cf)

+ 3 - 3
src/typing/typeloadFunction.ml

@@ -88,7 +88,7 @@ let type_function ctx args ret fmode f do_display p =
 	let fargs = List.map2 (fun (n,c,t) ((_,pn),_,m,_,_) ->
 		if starts_with n '$' then error "Function argument names starting with a dollar are not allowed" p;
 		let c = type_function_arg_value ctx t c do_display in
-		let v,c = add_local_with_origin ctx VUser n t pn (TVarOrigin.TVOArgument), c in
+		let v,c = add_local_with_origin ctx TVOArgument n t pn , c in
 		v.v_meta <- v.v_meta @ m;
 		if do_display && DisplayPosition.encloses_display_position pn then
 			DisplayEmitter.display_variable ctx v pn;
@@ -243,12 +243,12 @@ let add_constructor ctx c force_constructor p =
 					| TFun (args,_) ->
 						List.map (fun (n,o,t) ->
 							let def = try type_function_arg_value ctx t (Some (PMap.find n values)) false with Not_found -> if o then Some TNull else None in
-							map_arg (alloc_var VUser n (if o then ctx.t.tnull t else t) p,def) (* TODO: var pos *)
+							map_arg (alloc_var (VUser TVOArgument) n (if o then ctx.t.tnull t else t) p,def) (* TODO: var pos *)
 						) args
 					| _ -> assert false
 			) in
 			let p = c.cl_pos in
-			let vars = List.map (fun (v,def) -> alloc_var VUser v.v_name (apply_params csup.cl_params cparams v.v_type) v.v_pos, def) args in
+			let vars = List.map (fun (v,def) -> alloc_var (VUser TVOArgument) v.v_name (apply_params csup.cl_params cparams v.v_type) v.v_pos, def) args in
 			let super_call = mk (TCall (mk (TConst TSuper) (TInst (csup,cparams)) p,List.map (fun (v,_) -> mk (TLocal v) v.v_type p) vars)) ctx.t.tvoid p in
 			let constr = mk (TFunction {
 				tf_args = vars;

+ 4 - 5
src/typing/typer.ml

@@ -1481,15 +1481,14 @@ and type_vars ctx vl p =
 					Some e
 			) in
 			if starts_with v '$' then display_error ctx "Variables names starting with a dollar are not allowed" p;
-			let v = add_local_with_origin ctx VUser v t pv TVarOrigin.TVOLocalVariable in
-			v.v_meta <- (Meta.UserVariable,[],pv) :: v.v_meta;
+			let v = add_local_with_origin ctx TVOLocalVariable v t pv in
 			if ctx.in_display && DisplayPosition.encloses_display_position pv then
 				DisplayEmitter.display_variable ctx v pv;
 			v,e
 		with
 			Error (e,p) ->
 				check_error ctx e p;
-				add_local ctx VUser v t_dynamic pv, None (* TODO: What to do with this... *)
+				add_local ctx VGenerated v t_dynamic pv, None (* TODO: What to do with this... *)
 	) vl in
 	match vl with
 	| [v,eo] ->
@@ -1878,7 +1877,7 @@ and type_try ctx e1 catches with_type p =
 		if starts_with v '$' then display_error ctx "Catch variable names starting with a dollar are not allowed" p;
 		check_unreachable acc1 t2 (pos e_ast);
 		let locals = save_locals ctx in
-		let v = add_local_with_origin ctx VUser v t pv (TVarOrigin.TVOCatchVariable) in
+		let v = add_local_with_origin ctx TVOCatchVariable v t pv in
 		if ctx.is_display_file && DisplayPosition.encloses_display_position pv then
 			DisplayEmitter.display_variable ctx v pv;
 		let e = type_expr ctx e_ast with_type in
@@ -2020,7 +2019,7 @@ and type_local_function ctx name f with_type p =
 		| None -> None
 		| Some v ->
 			if starts_with v '$' then display_error ctx "Variable names starting with a dollar are not allowed" p;
-			let v = (add_local_with_origin ctx VUser v ft pname (TVarOrigin.TVOLocalFunction)) in
+			let v = (add_local_with_origin ctx TVOLocalFunction v ft pname) in
 			if params <> [] then v.v_extra <- Some (params,None);
 			Some v
 	) in

+ 1 - 1
tests/optimization/src/TestJs.hx

@@ -91,7 +91,7 @@ class TestJs {
 		forEach(function(x) use(x + 2));
 	}
 
-	@:js('var a = "";var e;var _hx_tmp = a.toLowerCase();if(_hx_tmp == "e") {e = 0;} else {throw new Error();}')
+	@:js('var a = "";var e;if(a.toLowerCase() == "e") {e = 0;} else {throw new Error();}')
 	@:analyzer(no_const_propagation, no_local_dce, no_copy_propagation)
 	static function testRValueSwitchWithExtractors() {
 		var a = "";