# FirstPosition returning an error message together with the correct answer [duplicate]

I have the following code:

Module[{lst},
lst = {
{1, 37, 2, 22},
{3, 59, 9, 9},
{6, 1, 32, 56},
{31, 42, 46, 27},
{58, 38, 64, 47}
};
FirstPosition[lst, x_ /; (x[[2]] == 42)]
(* Also tried the following, with the same result *)
(* FirstPosition[lst, _?(x[[2]] == 42 &)] *)
]


The code is simple enough, but I get the following error message before getting the right answer:

• @rasher Can you please provide the correct expression? FirstPosition[lst, x_ /; (x[[2]] == 42), 1, 1] returns the first line of the error message above. – Shredderroy Mar 18 '15 at 7:43
• A simpler form that achieves the same result is FirstPosition[lst, 42][[1]] – Gordon Coale Mar 18 '15 at 8:41
• FirstPosition[lst, x_ /; (Length[x]>=2 && x[[2]] == 42)], or FirstPosition[lst, x_List/; (x[[2]] == 42)] if it is safe to assume al expressions are lists that have a length of at least 2. – Michael E2 Mar 18 '15 at 10:09
• It's not a bug, just a bit of a nuisance. You need to specify level 1 only, and no heads are to be checked. This first necessitates that you also provide a default value. FirstPosition[lst, x_ /; (x[[2]] == 42), Missing["IWasAPoorlyDesignedArgument"], {1}, Heads -> False] should do what you want – Daniel Lichtblau Mar 18 '15 at 15:38