Skip to content

Typedef quasi-macro record fails when the macro name is customized #14963

@adamwight

Description

@adamwight

Elixir and Erlang/OTP versions

Erlang/OTP 27 [erts-15.2.3] [source-e02b4e39b5] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

Elixir 1.18.3 (compiled with Erlang/OTP 27)

Operating system

Linux (Debian 13.2)

Current behavior

Minimal case:

defmodule CustomType do
  require Record
  Record.defrecord(:new, :custom_name, field: :undefined)
  @type t :: record(:custom_name, field: term())
end

Output:

** (Kernel.TypespecError) iex:89: unknown record :custom_name
    (elixir 1.18.3) lib/kernel/typespec.ex:980: Kernel.Typespec.compile_error/2
    (elixir 1.18.3) lib/kernel/typespec.ex:308: Kernel.Typespec.translate_type/2
    (stdlib 6.2.1) lists.erl:2343: :lists.mapfoldl_1/3
    (elixir 1.18.3) lib/kernel/typespec.ex:235: Kernel.Typespec.translate_typespecs_for_module/2
    (elixir 1.18.3) src/elixir_erl.erl:140: :elixir_erl.compile/1
    (elixir 1.18.3) src/elixir_module.erl:216: anonymous fn/9 in :elixir_module.compile/7
    iex:86: (file)

Expected behavior

I would expect the code to work the same as in this example where the record function name was not customized:

defmodule CustomType do
  require Record
  Record.defrecord(:custom_name, field: :undefined)
  @type t :: record(:custom_name, field: term())
end

(no error)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions