aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2010-03-12 09:39:23 +0100
committerBjörn Gustavsson <[email protected]>2010-06-02 11:51:25 +0200
commit7ac0808979534a94617c3391503c961d1ef72755 (patch)
treef929be0d00318569bef8d37ecf316512b17a1b19 /lib/stdlib/test
parent1858cb81391d2bce29b4b7620574ca60128cebf7 (diff)
downloadotp-7ac0808979534a94617c3391503c961d1ef72755.tar.gz
otp-7ac0808979534a94617c3391503c961d1ef72755.tar.bz2
otp-7ac0808979534a94617c3391503c961d1ef72755.zip
Evaluate element/2 at compile-time using type information
The erl_expand_records compiler pass translates the following code: h(X) when X#r1.a =:= 1 -> ok. to (essentially): h({r1,V1,V2}=X) when element(2, X) =:= 1 -> ok. Since the guard can only be executed when the pattern matching has succeeded, we know that the second element in the tuple X must have been bound to V2. Thus we can eliminate the call to element/2 like this: h({r1,V1,V2}=X) when V1 =:= 1 -> ok.
Diffstat (limited to 'lib/stdlib/test')
-rw-r--r--lib/stdlib/test/qlc_SUITE.erl4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/stdlib/test/qlc_SUITE.erl b/lib/stdlib/test/qlc_SUITE.erl
index aa12ed57da..e21de8770a 100644
--- a/lib/stdlib/test/qlc_SUITE.erl
+++ b/lib/stdlib/test/qlc_SUITE.erl
@@ -3184,7 +3184,9 @@ lookup2(Config) when is_list(Config) ->
[] = qlc:e(Q),
false = lookup_keys(Q)
end, [{1,b},{2,3}])">>,
- {warnings,[{{3,48},qlc,nomatch_filter}]}},
+ {warnings,[{2,sys_core_fold,nomatch_guard},
+ {3,qlc,nomatch_filter},
+ {3,sys_core_fold,{eval_failure,badarg}}]}},
<<"etsc(fun(E) ->
Q = qlc:q([X || {X} <- ets:table(E), element(1,{X}) =:= 1]),