-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Milestone
Description
Environment
- Elixir & Erlang/OTP versions (elixir --version):
Erlang/OTP 21 [erts-10.1.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]
Elixir 1.8.0 (compiled with Erlang/OTP 21)
- Operating system: Fedora 29
Current behavior
You can no longer create a user defined type with the name record
.
Found this bug when compiling cachex which gave the following error:
== Compilation error in file lib/cachex/spec/validator.ex ==
** (CompileError) lib/cachex/spec/validator.ex:36: invalid record specification, expected the record name to be an atom
(elixir) lib/kernel/typespec.ex:875: Kernel.Typespec.compile_error/2
(elixir) lib/enum.ex:1431: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
(elixir) lib/enum.ex:1431: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
(elixir) lib/kernel/typespec.ex:927: Kernel.Typespec.fn_args/5
(elixir) lib/kernel/typespec.ex:913: Kernel.Typespec.fn_args/6
(elixir) lib/kernel/typespec.ex:366: Kernel.Typespec.translate_spec/8
(elixir) lib/enum.ex:1431: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
(elixir) lib/kernel/typespec.ex:223: Kernel.Typespec.translate_typespecs_for_module/2
Expected behavior
Users should be able to define their own types with the name record
as they were able to in previous versions of Elixir.
Minimal Example
defmodule Bug do
@type record :: binary
@spec foo?(record) :: boolean
def foo?(_), do: true
end
Produces:
$ elixir bug.exs
** (CompileError) bug.exs:3: invalid record specification, expected the record name to be an atom
(elixir) lib/kernel/typespec.ex:875: Kernel.Typespec.compile_error/2
(elixir) lib/enum.ex:1431: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
(elixir) lib/kernel/typespec.ex:927: Kernel.Typespec.fn_args/5
(elixir) lib/kernel/typespec.ex:913: Kernel.Typespec.fn_args/6
(elixir) lib/kernel/typespec.ex:366: Kernel.Typespec.translate_spec/8
(elixir) lib/enum.ex:1431: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
(elixir) lib/kernel/typespec.ex:223: Kernel.Typespec.translate_typespecs_for_module/2