Skip to content

Instantly share code, notes, and snippets.

@chrismccord
Created December 5, 2013 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrismccord/7806146 to your computer and use it in GitHub Desktop.
Save chrismccord/7806146 to your computer and use it in GitHub Desktop.
Elixir 0.11 record bug
# This worked on 0.10
defmodule Records do
defmacro __using__(_) do
quote do
defrecord A, name: "chris"
defrecord B, id: nil, nested: A.new
end
end
end
defmodule Example do
use Records
end
# On 0.11 throws == Compilation error on file ./record_bug.ex ==
# ** (UndefinedFunctionError) undefined function: A.new/0
# Updating to use __MODULE__ prefix fixes issues on 0.11
defmodule Records do
defmacro __using__(_) do
quote do
defrecord A, name: "chris"
defrecord B, id: nil, nested: __MODULE__.A.new
end
end
end
defmodule Example do
use Records
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment