Elixir: @spec module attribute no longer accessible in 1.7

Created on 15 Aug 2018  路  3Comments  路  Source: elixir-lang/elixir

Current behavior

defmodule Foo do
  @spec x() :: integer()
  def x(), do: 5
  def spec(), do: @spec
end

iex> Foo.spec() #=> nil

Expected behavior

iex> Foo.spec() #=>
[
  {:spec, {:::, [line: 2], [{:x, [line: 2], nil}, {:integer, [line: 2], []}]},
   {Foo, {2, 1}}}
]
Elixir Bug Discussion

Most helpful comment

I was accessing @spec via Module.get_attribute(__MODULE__, :spec) in defmacro __before_compile__(_). Same observations.

All 3 comments

I was accessing @spec via Module.get_attribute(__MODULE__, :spec) in defmacro __before_compile__(_). Same observations.

also would love a fix for this, my precious behaves_like is broken 馃槶

Same here - type-checking of foreign function interface to Elixir in Elchemy relies on it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LucianaMarques picture LucianaMarques  路  3Comments

lukaszsamson picture lukaszsamson  路  3Comments

andrewcottage picture andrewcottage  路  3Comments

josevalim picture josevalim  路  3Comments

sashaafm picture sashaafm  路  3Comments