Skip to content

Compiler goes into an infinite loop with invalid @type #14153

@filterfish

Description

@filterfish

Elixir and Erlang/OTP versions

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

Elixir 1.17.3 (compiled with Erlang/OTP 27)

Operating system

Debian Linux (sid)

Current behaviour

I've been playing around with types and I made error in the @type. I added t().String instead of String.t() (from this example) and the compiler went into an infinite loop. The full code fragment is:

defmodule Foo do                    
  @typedoc "A product"    
  @type product() :: t().String   
end

Other observations:

  • t.String also fails
  • T.String compiles
  • t.String followed by T.String fails with the following message:
== Compilation error in file lib/foo.ex ==
** (Kernel.TypespecError) lib/foo.ex:10: type product/0 is already defined in lib/foo.ex:9
    (elixir 1.17.3) lib/kernel/typespec.ex:969: Kernel.Typespec.compile_error/2
    (stdlib 6.1.2) lists.erl:2151: :lists.foldl_1/3
    (elixir 1.17.3) lib/kernel/typespec.ex:226: Kernel.Typespec.translate_typespecs_for_module/2

Expected behaviour

The compiler should report an 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