If-statement in body causes warning message
Closed this issue · 3 comments
miaout17 commented
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:
josevalim commented
The second one never raises warnings because it is never compiled, just executed. :) I have just pushed a fix, thanks for reporting!