Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- defmodule TestMacro do
- defmacro test_macro do
- quote do
- IO.inspect(var!(name))
- end
- end
- end
- defmodule Gen do
- defmacro __using__(_args) do
- quote do
- @before_compile unquote(__MODULE__)
- end
- end
- defmacro __before_compile__(_env) do
- quote do
- def test do
- name = "test"
- test_macro
- end
- end
- end
- end
- defmodule User do
- import TestMacro
- use Gen
- end
- # ** (CompileError) iex:6: expected var "name" to expand to an existing variable or be part of a match
- # (elixir) expanding macro: Kernel.var!/1
- # iex:6: User.test/0
- # expanding macro: TestMacro.test_macro/0
- # iex:6: User.test/0
- # iex:6: Gen.__before_compile__/1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement