[erlang-questions] Weird function match semantics

Bjorn Gustavsson <>
Sat Nov 17 10:48:14 CET 2007


"Matthew Dempsky" <> writes:

> I expect the following three expressions to evaluate to 'ok':
> 
>     (fun("X" ++ _) -> ok end)("X").
>     (fun([$X | _]) -> ok end)("X").
>     (fun([$X] ++ _) -> ok end)("X").
> 
> The first two meet my expectations, but the third exits with an
> illegal_pattern exception.  Is this intentional or a bug?

It does seems to be a bug in the evaluator. It works fine in
compiled code. If time permits we will fix it in R12B-0.

/Bjorn
-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list