elixir-lang/elixir

If-statement in body causes warning message

Closed this issue · 3 comments

When running following code:

module Iftest
  def test
    if true
      IO.puts "if true works"
    else
      IO.puts "if true fails"
    end

    if false
      IO.puts "if false fails"
    else
      IO.puts "if false works"
    end
  end
end

Iftest.test

It works properly, but it causes some Erlang warning messages:

src/../play/iftest2.ex:3: this clause cannot match because of different types/sizes
src/../play/iftest2.ex:9: this clause cannot match because of different types/sizes

However, if the if-statement is not in a function body, the warning message is not shown:

if true
  IO.puts "if true works"
else
  IO.puts "if true fails"
end

if false
  IO.puts "if false fails"
else
  IO.puts "if false works"
end

Sample code is available at my repository:

The second one never raises warnings because it is never compiled, just executed. :) I have just pushed a fix, thanks for reporting!

Ignore nomatch_clause_type warnings, closed by 02b7339

wow accidentally got pointed here by typing "#1" in IRC. Syntax blast from a past I was not involved in :)