Can not define type in a non-Elixir module
xhh opened this issue · comments
xhh 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)
xhh 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
.
Qqwy / Marten commented
Thank you very much! This indeed seems like a bug. I'll try to fix it shortly.
Qqwy / Marten commented
Version 0.13.3 has been published, which includes a fix for this bug.