josevalim/elixir — Issue #99: __FILE__ and __LINE__ semantics needs to be adjusted in macros
Author: josevalim
Created: 2012-01-10 12:54:18+00:00
State: open
Labels: Bug

Expected behavior:

__FILE__ and __LINE__ inside a quote should always return the value regarding the context where they were applied.

For instance:

# macro.ex
defmodule Macro do
defmacro demo, do: quote { { __FILE__, __LINE__ } }
end

# usage.ex
defmodule Usage do
require Macro
Macro.demo
end

The example above, will return: `{ 'usage.ex', 2 }`. This means the filename is correct (being attached to current scope), but not the line number. The same error happens for eval_quoted.

On the other hand, when there is an exception (for example, an invalid function), the file and line number in the error message should come from the macro. Today we are printing the wrong file number (it comes from the applied scope) and 0 as line number.