Possible bug on the Shell.say code
Selvaticus opened this issue · comments
Hi,
While working on the issue 35, I came across what I think its a bug on the Shell.say
function.
This is the function definition:
@spec say(String.t) :: none()
def say(message) when is_input(message), do: say(message, [])
@spec say(any) :: none()
def say(_any), do: raise ArgumentError, message: "Invalid argument, accept String or List!"
@spec say(String.t, Keyword.t) :: none()
def say(message, opts) do
case Keyword.get(opts, :silent) do
nil ->
IO.puts message
true ->
nil
end
end
I assume the is_input
guard will be completely bypassed if the function is called with 2 parameter as the third definition will match anything with 2 parameters def say(message, opts)
hence is possible to call the Shell.say
with types other than String
or List
Does this sound correct or am I missing something obvious?
Cheers
Main idea here print to console strings. So string could be represented as List
, and 'String'. I didn't try to print other.
But here i see point to think about. That if I want to Print other structures.
For now you need cast to string that you want to print to console