Honestly though I’m not sure why you would want to manipulate the source compile attribute. source and vsn are 2 quick checks in production that you are running the modules you think you should be running.
q = quote do
def foo, do: 1/0
def bar, do: 2/0
end
Module.create(Y, q, Map.put(__ENV__, :file, "y.ex"))
then when calling Y.foo() and Y.bar() the lines in the stracktraces are the same. I think this is because quote does not add metadata line: number in this case (only when the quotes are generated by the compiler when calling macros do they get the line: number metadata).
I also tried to do quote location: :keep do ... but then the file is the physical file, not y.ex.
The only solution I found is to do Macro.postwalk to add the metadata keep: {"y.ex", number} on every node that has the metadata line: number.
This solution is working well, but a more direct way would be preferable. The possibilities are:
have @file set the file for all following functions and macros, not only the next one
support quote location: "filepath" do and quote lines: true do
In fact, I think both points 1) and 2) would be useful for my and other use cases.