Report invalid element errors closer to user code

Now user's code line will start on 2nd line
instead of 3rd.