dwango / fialyzer

[WIP] Faster Implementation of Dialyzer
https://dwango.github.io/fialyzer/
Apache License 2.0
56 stars 8 forks source link

Support match expressions #128

Closed amutake closed 5 years ago

amutake commented 5 years ago

resolves #81

I added support for match expressions.

algorithm

Let us consider an expression E = fun () -> A = B = f(C = 1), f(A + B + C) end for example. By extract_match_expr, expression E is converted to fun () -> C = 1, B = f(1), A = f(1), f(A + B + C) end (= E'). By expr_of_erlang_expr' and expr_of_erlang_exprs, expression E' is converted to:

fun () -> 
  case 1 of
    C -> case f(1) of
           B -> case f(1) of
                  A -> f(A + B + C)
                end
         end
  end
end

Although f(1) is called multiple times, I suspect it is no problem because fialyzer is a type checker, not a compiler/interpreter.

minimum prototype

https://gist.github.com/amutake/0dc3e07a58511fed494a5676904d4eea