aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler
diff options
context:
space:
mode:
authorAnthony Ramine <[email protected]>2012-11-05 17:04:07 +0100
committerFredrik Gustafsson <[email protected]>2013-01-16 15:05:42 +0100
commit7b0b3688ba8b921b8cc1eff39ed39a14c424d557 (patch)
treeae31c6aba28aeaa5ef67b33100fe492590e9e32c /lib/compiler
parent572d66b1e4a5d5e519f89881a18bdf4f2745f62c (diff)
downloadotp-7b0b3688ba8b921b8cc1eff39ed39a14c424d557.tar.gz
otp-7b0b3688ba8b921b8cc1eff39ed39a14c424d557.tar.bz2
otp-7b0b3688ba8b921b8cc1eff39ed39a14c424d557.zip
Raise a function_clause error with the right arguments when inlining
The inlined lists functions raised an error with only the list instead of all their given arguments.
Diffstat (limited to 'lib/compiler')
-rw-r--r--lib/compiler/src/sys_core_fold.erl20
-rw-r--r--lib/compiler/test/inline_SUITE.erl48
2 files changed, 38 insertions, 30 deletions
diff --git a/lib/compiler/src/sys_core_fold.erl b/lib/compiler/src/sys_core_fold.erl
index a09d80ac3f..f17b0bd130 100644
--- a/lib/compiler/src/sys_core_fold.erl
+++ b/lib/compiler/src/sys_core_fold.erl
@@ -691,7 +691,7 @@ call_1(#c_call{anno=Anno}, lists, all, [Arg1,Arg2], Sub) ->
name=#c_literal{val=is_function},
args=[F, #c_literal{val=1}]},
body=#c_literal{val=true}},
- Err2 = #c_tuple{es=[#c_literal{val='function_clause'}, Xs]},
+ Err2 = #c_tuple{es=[#c_literal{val='function_clause'}, F, Xs]},
C3 = #c_clause{pats=[Xs], guard=#c_literal{val=true},
body=match_fail([{function_name,{'lists^all',1}}|Anno], Err2)},
Fun = #c_fun{vars=[Xs],
@@ -721,7 +721,7 @@ call_1(#c_call{anno=Anno}, lists, any, [Arg1,Arg2], Sub) ->
name=#c_literal{val=is_function},
args=[F, #c_literal{val=1}]},
body=#c_literal{val=false}},
- Err2 = #c_tuple{es=[#c_literal{val='function_clause'}, Xs]},
+ Err2 = #c_tuple{es=[#c_literal{val='function_clause'}, F, Xs]},
C3 = #c_clause{pats=[Xs], guard=#c_literal{val=true},
body=match_fail([{function_name,{'lists^any',1}}|Anno], Err2)},
Fun = #c_fun{vars=[Xs],
@@ -744,7 +744,7 @@ call_1(#c_call{anno=Anno}, lists, foreach, [Arg1,Arg2], Sub) ->
name=#c_literal{val=is_function},
args=[F, #c_literal{val=1}]},
body=#c_literal{val=ok}},
- Err = #c_tuple{es=[#c_literal{val='function_clause'}, Xs]},
+ Err = #c_tuple{es=[#c_literal{val='function_clause'}, F, Xs]},
C3 = #c_clause{pats=[Xs], guard=#c_literal{val=true},
body=match_fail([{function_name,{'lists^foreach',1}}|Anno], Err)},
Fun = #c_fun{vars=[Xs],
@@ -774,7 +774,7 @@ call_1(#c_call{anno=Anno}, lists, map, [Arg1,Arg2], Sub) ->
name=#c_literal{val=is_function},
args=[F, #c_literal{val=1}]},
body=#c_literal{val=[]}},
- Err = #c_tuple{es=[#c_literal{val='function_clause'}, Xs]},
+ Err = #c_tuple{es=[#c_literal{val='function_clause'}, F, Xs]},
C3 = #c_clause{pats=[Xs], guard=#c_literal{val=true},
body=match_fail([{function_name,{'lists^map',1}}|Anno], Err)},
Fun = #c_fun{vars=[Xs],
@@ -805,7 +805,7 @@ call_1(#c_call{anno=Anno}, lists, flatmap, [Arg1,Arg2], Sub) ->
name=#c_literal{val=is_function},
args=[F, #c_literal{val=1}]},
body=#c_literal{val=[]}},
- Err = #c_tuple{es=[#c_literal{val='function_clause'}, Xs]},
+ Err = #c_tuple{es=[#c_literal{val='function_clause'}, F, Xs]},
C3 = #c_clause{pats=[Xs], guard=#c_literal{val=true},
body=match_fail([{function_name,{'lists^flatmap',1}}|Anno], Err)},
Fun = #c_fun{vars=[Xs],
@@ -842,7 +842,7 @@ call_1(#c_call{anno=Anno}, lists, filter, [Arg1,Arg2], Sub) ->
name=#c_literal{val=is_function},
args=[F, #c_literal{val=1}]},
body=#c_literal{val=[]}},
- Err2 = #c_tuple{es=[#c_literal{val='function_clause'}, Xs]},
+ Err2 = #c_tuple{es=[#c_literal{val='function_clause'}, F, Xs]},
C3 = #c_clause{pats=[Xs], guard=#c_literal{val=true},
body=match_fail([{function_name,{'lists^filter',1}}|Anno], Err2)},
Fun = #c_fun{vars=[Xs],
@@ -869,7 +869,7 @@ call_1(#c_call{anno=Anno}, lists, foldl, [Arg1,Arg2,Arg3], Sub) ->
name=#c_literal{val=is_function},
args=[F, #c_literal{val=2}]},
body=A},
- Err = #c_tuple{es=[#c_literal{val='function_clause'}, Xs]},
+ Err = #c_tuple{es=[#c_literal{val='function_clause'}, F, A, Xs]},
C3 = #c_clause{pats=[Xs], guard=#c_literal{val=true},
body=match_fail([{function_name,{'lists^foldl',2}}|Anno], Err)},
Fun = #c_fun{vars=[Xs, A],
@@ -896,7 +896,7 @@ call_1(#c_call{anno=Anno}, lists, foldr, [Arg1,Arg2,Arg3], Sub) ->
name=#c_literal{val=is_function},
args=[F, #c_literal{val=2}]},
body=A},
- Err = #c_tuple{es=[#c_literal{val='function_clause'}, Xs]},
+ Err = #c_tuple{es=[#c_literal{val='function_clause'}, F, A, Xs]},
C3 = #c_clause{pats=[Xs], guard=#c_literal{val=true},
body=match_fail([{function_name,{'lists^foldr',2}}|Anno], Err)},
Fun = #c_fun{vars=[Xs, A],
@@ -949,7 +949,7 @@ call_1(#c_call{anno=Anno}, lists, mapfoldl, [Arg1,Arg2,Arg3], Sub) ->
es=[#c_literal{val=[]}, Avar]}},
%%% Multiple-value version
%%% body=#c_values{es=[#c_literal{val=[]}, A]}},
- Err = #c_tuple{es=[#c_literal{val='function_clause'}, Xs]},
+ Err = #c_tuple{es=[#c_literal{val='function_clause'}, F, Avar, Xs]},
C3 = #c_clause{pats=[Xs], guard=#c_literal{val=true},
body=match_fail([{function_name,{'lists^mapfoldl',2}}|Anno], Err)},
Fun = #c_fun{vars=[Xs, Avar],
@@ -1010,7 +1010,7 @@ call_1(#c_call{anno=Anno}, lists, mapfoldr, [Arg1,Arg2,Arg3], Sub) ->
es=[#c_literal{val=[]}, Avar]}},
%%% Multiple-value version
%%% body=#c_values{es=[#c_literal{val=[]}, A]}},
- Err = #c_tuple{es=[#c_literal{val='function_clause'}, Xs]},
+ Err = #c_tuple{es=[#c_literal{val='function_clause'}, F, Avar, Xs]},
C3 = #c_clause{pats=[Xs], guard=#c_literal{val=true},
body=match_fail([{function_name,{'lists^mapfoldr',2}}|Anno], Err)},
Fun = #c_fun{vars=[Xs, Avar],
diff --git a/lib/compiler/test/inline_SUITE.erl b/lib/compiler/test/inline_SUITE.erl
index 63180c3f95..e7bb552edb 100644
--- a/lib/compiler/test/inline_SUITE.erl
+++ b/lib/compiler/test/inline_SUITE.erl
@@ -256,38 +256,46 @@ lists(Config) when is_list(Config) ->
%% Cleanup.
erase(?MODULE),
- {'EXIT',{function_clause,_}} =
+ {'EXIT',{function_clause,[{?MODULE,_,[_,not_a_list],_}|_]}} =
(catch lists:map(fun (X) -> X end, not_a_list)),
- {'EXIT',{function_clause,_}} =
+ {'EXIT',{function_clause,[{?MODULE,_,[_,not_a_list],_}|_]}} =
(catch lists:flatmap(fun (X) -> X end, not_a_list)),
- {'EXIT',{function_clause,_}} =
+ {'EXIT',{function_clause,[{?MODULE,_,[_,not_a_list],_}|_]}} =
(catch lists:foreach(fun (X) -> X end, not_a_list)),
- {'EXIT',{function_clause,_}} =
+ {'EXIT',{function_clause,[{?MODULE,_,[_,not_a_list],_}|_]}} =
(catch lists:filter(fun (_) -> true end, not_a_list)),
- {'EXIT',{function_clause,_}} =
+ {'EXIT',{function_clause,[{?MODULE,_,[_,not_a_list],_}|_]}} =
(catch lists:any(fun (_) -> false end, not_a_list)),
- {'EXIT',{function_clause,_}} =
+ {'EXIT',{function_clause,[{?MODULE,_,[_,not_a_list],_}|_]}} =
(catch lists:all(fun (_) -> true end, not_a_list)),
- {'EXIT',{function_clause,_}} =
+ {'EXIT',{function_clause,[{?MODULE,_,[_,acc,not_a_list],_}|_]}} =
(catch lists:foldl(fun (X, Acc) -> {X,Acc} end, acc, not_a_list)),
- {'EXIT',{function_clause,_}} =
+ {'EXIT',{function_clause,[{?MODULE,_,[_,acc,not_a_list],_}|_]}} =
(catch lists:foldr(fun (X, Acc) -> {X,Acc} end, acc, not_a_list)),
- {'EXIT',{function_clause,_}} =
+ {'EXIT',{function_clause,[{?MODULE,_,[_,acc,not_a_list],_}|_]}} =
(catch lists:mapfoldl(fun (X, Acc) -> {X,Acc} end, acc, not_a_list)),
- {'EXIT',{function_clause,_}} =
+ {'EXIT',{function_clause,[{?MODULE,_,[_,acc,not_a_list],_}|_]}} =
(catch lists:mapfoldr(fun (X, Acc) -> {X,Acc} end, acc, not_a_list)),
- {'EXIT',{function_clause,_}} = (catch lists:map(not_a_function, [])),
- {'EXIT',{function_clause,_}} = (catch lists:flatmap(not_a_function, [])),
- {'EXIT',{function_clause,_}} = (catch lists:foreach(not_a_function, [])),
- {'EXIT',{function_clause,_}} = (catch lists:filter(not_a_function, [])),
- {'EXIT',{function_clause,_}} = (catch lists:any(not_a_function, [])),
- {'EXIT',{function_clause,_}} = (catch lists:all(not_a_function, [])),
- {'EXIT',{function_clause,_}} = (catch lists:foldl(not_a_function, acc, [])),
- {'EXIT',{function_clause,_}} = (catch lists:foldr(not_a_function, acc, [])),
- {'EXIT',{function_clause,_}} =
+ {'EXIT',{function_clause,[{?MODULE,_,[not_a_function,[]],_}|_]}} =
+ (catch lists:map(not_a_function, [])),
+ {'EXIT',{function_clause,[{?MODULE,_,[not_a_function,[]],_}|_]}} =
+ (catch lists:flatmap(not_a_function, [])),
+ {'EXIT',{function_clause,[{?MODULE,_,[not_a_function,[]],_}|_]}} =
+ (catch lists:foreach(not_a_function, [])),
+ {'EXIT',{function_clause,[{?MODULE,_,[not_a_function,[]],_}|_]}} =
+ (catch lists:filter(not_a_function, [])),
+ {'EXIT',{function_clause,[{?MODULE,_,[not_a_function,[]],_}|_]}} =
+ (catch lists:any(not_a_function, [])),
+ {'EXIT',{function_clause,[{?MODULE,_,[not_a_function,[]],_}|_]}} =
+ (catch lists:all(not_a_function, [])),
+ {'EXIT',{function_clause,[{?MODULE,_,[not_a_function,acc,[]],_}|_]}} =
+ (catch lists:foldl(not_a_function, acc, [])),
+ {'EXIT',{function_clause,[{?MODULE,_,[not_a_function,acc,[]],_}|_]}} =
+ (catch lists:foldr(not_a_function, acc, [])),
+ {'EXIT',{function_clause,[{?MODULE,_,[not_a_function,acc,[]],_}|_]}} =
(catch lists:mapfoldl(not_a_function, acc, [])),
- {'EXIT',{function_clause,_}} =
+ {'EXIT',{function_clause,[{?MODULE,_,[not_a_function,acc,[]],_}|_]}} =
(catch lists:mapfoldr(not_a_function, acc, [])),
ok.