bodhilogic

bodhilogic

@spec reports false error

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?

Marked As Solved

bodhilogic

bodhilogic

Nevermind - sorry good friends… I had a typo in my code :frowning:

Where Next?

Popular in Questions Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

Other popular topics Top

baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

We're in Beta

About us Mission Statement