Browse Source

display position of TFunction when requesting argument @position (see #2993)

Simon Krajewski 11 years ago
parent
commit
50618b0520

+ 2 - 0
codegen.ml

@@ -926,6 +926,8 @@ let detect_usage com =
 					usage := e.epos :: !usage
 				| TVar (v,_) when com.display = DMPosition && Meta.has Meta.Usage v.v_meta ->
 					raise (Typecore.DisplayPosition [e.epos])
+				| TFunction tf when com.display = DMPosition && List.exists (fun (v,_) -> Meta.has Meta.Usage v.v_meta) tf.tf_args ->
+					raise (Typecore.DisplayPosition [e.epos])
 				| TTypeExpr mt when (Meta.has Meta.Usage (t_infos mt).mt_meta) ->
 					usage := e.epos :: !usage
 				| _ -> Type.iter expr e

+ 6 - 0
tests/misc/projects/Issue2993/Main.hx

@@ -0,0 +1,6 @@
+class Main {
+    function f(arg) {
+        if (arg) trace(arg);
+        arg = false;
+    }
+}

+ 1 - 0
tests/misc/projects/Issue2993/compile.hxml

@@ -0,0 +1 @@
+--display Main.hx@76@position

+ 3 - 0
tests/misc/projects/Issue2993/compile.hxml.stderr

@@ -0,0 +1,3 @@
+<list>
+<pos>$$normPath(::cwd::/Main.hx):2: lines 2-5</pos>
+</list>