[erlang-bugs] Incorrect line number in stacktrace when using atom as binary

Stanislav Seletskiy s.seletskiy@REDACTED
Wed Jan 15 09:17:50 CET 2014


Recently I've stuck with error "** exception error: bad argument"
while doing obviously wrong <<A/binary>> (A :: atom()), but I've
noticed, that line number, that shows along with error message, was
incorrect.

Consider this code:
-module(bug).

-export([
    test/1
]).

test(A) ->
    erlang:display(A),
    <<A/binary>>.

Let's compile it and run in shell (R16B03, B02 is also affected):
1> bug:test(atom).
atom
** exception error: bad argument
     in function  bug:test/1 (src/bug.erl, line 8)

So, as we can see, line 8 is pointed at "erlang:display(A)", but error
was occured on line 9. It can be very confusing while debugging large
modules. I think it's a bug because of it points on invalid line and
with other errors there is no such behaviour.

Thanks for attention.

-- 
Stanislav Seletskiy



More information about the erlang-bugs mailing list