diff options
author | José Valim <[email protected]> | 2012-11-28 12:51:34 +0100 |
---|---|---|
committer | Fredrik Gustafsson <[email protected]> | 2013-01-25 14:57:00 +0100 |
commit | 261880cfbebafddb61c728ed873f4e93107d9af9 (patch) | |
tree | 91f999d0924b3ec41e3fb486e34ab5fbcf9ad87e | |
parent | f3fb48d42329d54b463e7434ff28bb51e4dde4dd (diff) | |
download | otp-261880cfbebafddb61c728ed873f4e93107d9af9.tar.gz otp-261880cfbebafddb61c728ed873f4e93107d9af9.tar.bz2 otp-261880cfbebafddb61c728ed873f4e93107d9af9.zip |
Fix a bug in cover when used with no_auto_import
Cover was rewriting guard clauses as non-remote calls.
That said, if a guard contains erlang:is_binary(Binary),
Cover was incorrectly removing the erlang prefix which
lead to errors if is_binary is not auto imported.
This commit keeps the abstract format as it is.
-rw-r--r-- | lib/tools/src/cover.erl | 8 | ||||
-rw-r--r-- | lib/tools/test/cover_SUITE_data/compile_beam/v.erl | 7 |
2 files changed, 6 insertions, 9 deletions
diff --git a/lib/tools/src/cover.erl b/lib/tools/src/cover.erl index 3cf42662f8..2579711dc7 100644 --- a/lib/tools/src/cover.erl +++ b/lib/tools/src/cover.erl @@ -1799,17 +1799,11 @@ munge_expr({'catch',Line,Expr}, Vars) -> {MungedExpr, Vars2} = munge_expr(Expr, Vars), {{'catch',Line,MungedExpr}, Vars2}; munge_expr({call,Line1,{remote,Line2,ExprM,ExprF},Exprs}, - Vars) when Vars#vars.is_guard=:=false-> + Vars) -> {MungedExprM, Vars2} = munge_expr(ExprM, Vars), {MungedExprF, Vars3} = munge_expr(ExprF, Vars2), {MungedExprs, Vars4} = munge_exprs(Exprs, Vars3, []), {{call,Line1,{remote,Line2,MungedExprM,MungedExprF},MungedExprs}, Vars4}; -munge_expr({call,Line1,{remote,_Line2,_ExprM,ExprF},Exprs}, - Vars) when Vars#vars.is_guard=:=true -> - %% Difference in abstract format after preprocessing: BIF calls in guards - %% are translated to {remote,...} (which is not allowed as source form) - %% NOT NECESSARY FOR Vsn=raw_abstract_v1 - munge_expr({call,Line1,ExprF,Exprs}, Vars); munge_expr({call,Line,Expr,Exprs}, Vars) -> {MungedExpr, Vars2} = munge_expr(Expr, Vars), {MungedExprs, Vars3} = munge_exprs(Exprs, Vars2, []), diff --git a/lib/tools/test/cover_SUITE_data/compile_beam/v.erl b/lib/tools/test/cover_SUITE_data/compile_beam/v.erl index 007957297a..7fb0b08d40 100644 --- a/lib/tools/test/cover_SUITE_data/compile_beam/v.erl +++ b/lib/tools/test/cover_SUITE_data/compile_beam/v.erl @@ -1,6 +1,9 @@ -module(v). - --export([f/0]). +-compile({ no_auto_import, [is_integer/1] }). +-export([f/0,f/1]). f() -> ok. + +f(Number) when erlang:is_integer(Number) -> + Number. |