I’m trying to define a @spec that looks like this:
@type sql() :: String.t()
@spec query() :: sql()
The function takes no parameters and returns a string representing the SQL code that will be run in a database query.
When I start the phx.server, I am getting this error:
== Compilation error in file lib/mim_core/stuff.ex ==
** (CompileError) lib/mim_core/stuff.ex:108: misplaced operator ::/2
The :: operator is typically used in bitstrings to specify types and sizes of segments:
<<size::32-integer, letter::utf8, rest::binary>>
It is also used in typespecs, such as @type and @spec, to describe inputs and outputs
(elixir 1.13.4) expanding macro: Kernel.@/1
It knows that the :: can be found in a @spec though it doesn’t let my spec’s return typespec get past the error.
Is there a way to define the @spec so that it doesn’t generate a “misplaced operator ::/2” error?