From 57d5d8450811eb7c79b1365ab13fec689f8decdd Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sun, 24 Mar 2013 14:40:24 +0100 Subject: Fix optimization of some binary comprehensions If a variable bound in a generator is used as the size of a segment in the comprehension body, v3_core uses this variable in the code generated to compute the initial size given to the `bs_init_writable` primop before the variable is actually bound, as in: << <<0:S>> || S <- Slist >> Reported-By: Peer Stritzinger --- lib/compiler/test/bs_bincomp_SUITE.erl | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/compiler/test/bs_bincomp_SUITE.erl') diff --git a/lib/compiler/test/bs_bincomp_SUITE.erl b/lib/compiler/test/bs_bincomp_SUITE.erl index d39e340429..451a9b1e3b 100644 --- a/lib/compiler/test/bs_bincomp_SUITE.erl +++ b/lib/compiler/test/bs_bincomp_SUITE.erl @@ -282,6 +282,9 @@ sizes(Config) when is_list(Config) -> ?line <<1,2,3,0>> = Fun13(7), ?line <<1,2,3,0,0>> = Fun13(8), + <<0:3>> = cs_default(<< <<0:S>> || S <- [0,1,2] >>), + <<0:3>> = cs_default(<< <<0:S>> || <> <= <<0,1,2>> >>), + ?line {'EXIT',_} = (catch << <> || <> <= {1,2,3} >>), ?line cs_end(), -- cgit v1.2.3