diff options
author | Björn Gustavsson <[email protected]> | 2016-09-13 06:55:39 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2016-09-26 16:20:39 +0200 |
commit | ac3bbbe932f2e547d93ebdc7c3bf4c0e542f30bd (patch) | |
tree | 6c396ff389dfb63bbd82891aa7454e63ec00b04b /lib | |
parent | 3d9bbd259a7f8e29becf65476bf3bd8a32ad374e (diff) | |
download | otp-ac3bbbe932f2e547d93ebdc7c3bf4c0e542f30bd.tar.gz otp-ac3bbbe932f2e547d93ebdc7c3bf4c0e542f30bd.tar.bz2 otp-ac3bbbe932f2e547d93ebdc7c3bf4c0e542f30bd.zip |
sys_core_fold: Correct scope verification code
703e8f4490bf broke the scope verification code (by calling
ordsets:is_subset/2 with an unsorted second argument).
While we are it, also optimize the verification function
by avoiding converting the map to a sorted list.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compiler/src/sys_core_fold.erl | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/compiler/src/sys_core_fold.erl b/lib/compiler/src/sys_core_fold.erl index caa30a5ef4..79a45b1c7c 100644 --- a/lib/compiler/src/sys_core_fold.erl +++ b/lib/compiler/src/sys_core_fold.erl @@ -83,10 +83,11 @@ -ifdef(DEBUG). -define(ASSERT(E), case E of - true -> ok; + true -> + ok; false -> io:format("~p, line ~p: assertion failed\n", [?MODULE,?LINE]), - exit(assertion_failed) + error(assertion_failed) end). -else. -define(ASSERT(E), ignore). @@ -3442,12 +3443,18 @@ format_error(bin_var_used_in_guard) -> verify_scope(E, #sub{s=Scope}) -> Free0 = cerl_trees:free_variables(E), Free = [V || V <- Free0, not is_tuple(V)], %Ignore function names. - case ordsets:is_subset(Free, cerl_sets:to_list(Scope)) of - true -> true; + case is_subset_of_scope(Free, Scope) of + true -> + true; false -> io:format("~p\n", [E]), io:format("~p\n", [Free]), - io:format("~p\n", [cerl_sets:to_list(Scope)]), + io:format("~p\n", [ordsets:from_list(cerl_sets:to_list(Scope))]), false end. + +is_subset_of_scope([V|Vs], Scope) -> + cerl_sets:is_element(V, Scope) andalso is_subset_of_scope(Vs, Scope); +is_subset_of_scope([], _) -> true. + -endif. |