Qqwy / elixir-type_check

TypeCheck: Fast and flexible runtime type-checking for your Elixir projects.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can not define type in a non-Elixir module

xhh opened this issue · comments

commented

When defining type in a non-Elixir module:

defmodule :my_mod do
  use TypeCheck

  @type! str :: String.t()

  @spec! hello(str()) :: :ok
  def hello(name) do
    IO.puts("Hello #{name}!")
    :ok
  end
end

an compilation error occurs:

** (ArgumentError) expected an Elixir module, got: :my_mod
    (elixir 1.14.3) lib/module.ex:1677: Module.split/2
    (type_check 0.13.2) lib/type_check/macros.ex:626: TypeCheck.Macros.type_fun_definition/5
    (type_check 0.13.2) lib/type_check/macros.ex:536: TypeCheck.Macros.define_type/3
    lib/my_mod.ex:4: (module)
commented

It could be fixed by checking if the module is an Elixir module like this in the elixir_sense project before calling Module.split.

Thank you very much! This indeed seems like a bug. I'll try to fix it shortly.

Version 0.13.3 has been published, which includes a fix for this bug.