elixir-tools / spitfire

Error tolerant parser for Elixir
https://www.elixir-tools.dev
MIT License
69 stars 7 forks source link

`Spitfire.Env.expand/2` invalid typespec #42

Closed zachdaniel closed 2 months ago

zachdaniel commented 2 months ago

Its currently specced like so:

  @spec expand(Macro.t(), String.t()) ::
          {ast :: Macro.t(), final_state :: map(), final_env :: Macro.Env.t(), cursor_env :: Macro.Env.t()}

I have a function that returns the 3rd element from that tuple, also saying that it is a Macro.Env.t(). However, it isn't actually returning a Macro.Env.t() as far as I can tell, but a map with the same keys and some additional keys, w/o the struct? Not sure. But to address it on my end I did this:

    |> then(fn value ->
      # makes dialyzer happy?
      {:ok, Map.take(value, Map.keys(%Macro.Env{}))}
    end)

I don't know if that just breaks its inference or actually fixes anything though 😆