$ elixir --version
Erlang/OTP 20 [erts-9.2] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:10] [hipe] [kernel-poll:false]
Elixir 1.6.3 (compiled with OTP 19)
defmodule Dtest do
@doc """
## Examples
iex> tap(33, fn x -> "> #{x}" end)
33
"""
def tap(input, input_fun) do
input_fun.(input)
input
end
end
ExUnit.start()
defmodule DtestTest do
use ExUnit.Case
doctest Dtest, import: true
end
warning: variable "x" does not exist and is being expanded to "x()", please use parentheses to remove the ambiguity or change the variable name
opt/app/x.exs:4
** (CompileError) opt/app/x.exs:4: undefined function x/0
(elixir) src/elixir_bitstring.erl:60: :elixir_bitstring.expand_expr/4
(elixir) src/elixir_bitstring.erl:19: :elixir_bitstring.expand/6
(elixir) src/elixir_bitstring.erl:12: :elixir_bitstring.expand/4
(stdlib) lists.erl:1354: :lists.mapfoldl/3
(stdlib) lists.erl:1355: :lists.mapfoldl/3
(elixir) expanding macro: Kernel.@/1
Tests should be executed without any errors.
The documentation is also a string. So you are interpolating the outer string and not the example one. Writing @doc ~S""" should solve it as it disables interpolation.
Most helpful comment
The documentation is also a string. So you are interpolating the outer string and not the example one. Writing
@doc ~S"""should solve it as it disables interpolation.