From c7188f410f5d2688783dfbb850e1e55718885f87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Mon, 14 Mar 2011 15:15:09 +0100 Subject: v3_core: Fix variable incorrectly unbound after binary match In the following code: m(<>) -> Sz = wrong. the Sz variable is supposed to be bound in the function header and the matching "Sz = wrong" should cause a badarg exception. But what happens is that the Sz variables seems to be unbound and the matching succeds and the m/1 function returns 'wrong'. If the Sz variable is used directly (not matched), it will have the expected value. Thus the following code: m(<>) -> Sz. will correctly return the value of Sz that was matched out from the binary. Reported-by: Bernard Duggan --- lib/stdlib/test/erl_eval_SUITE.erl | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/stdlib') diff --git a/lib/stdlib/test/erl_eval_SUITE.erl b/lib/stdlib/test/erl_eval_SUITE.erl index 6b2eb78e2c..4b59cee99e 100644 --- a/lib/stdlib/test/erl_eval_SUITE.erl +++ b/lib/stdlib/test/erl_eval_SUITE.erl @@ -571,6 +571,17 @@ otp_5269(Config) when is_list(Config) -> B:A>> <- [<<16:8,19:16>>], <> <- [<>]].", [19]), + ?line check(fun() -> + (fun (<>) -> + case A of + B -> wrong; + _ -> ok + end + end)(<<1,2,3,4>>) end, + "(fun(<>) ->" + " case A of B -> wrong; _ -> ok end" + " end)(<<1, 2, 3, 4>>).", + ok), ok. otp_6539(doc) -> -- cgit v1.2.3