diff options
author | Hans Bolinder <[email protected]> | 2014-03-07 09:46:27 +0100 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2014-03-07 09:46:27 +0100 |
commit | 568a9213dbc195107b23e6604a68b60ff5646f58 (patch) | |
tree | 7827da4d5058ca65da8c479b71e09e998c9550eb /lib | |
parent | 4b7beb12a04415181053669a2b578efd6c647182 (diff) | |
download | otp-568a9213dbc195107b23e6604a68b60ff5646f58.tar.gz otp-568a9213dbc195107b23e6604a68b60ff5646f58.tar.bz2 otp-568a9213dbc195107b23e6604a68b60ff5646f58.zip |
Emit errors when redefining arity(), bitstring(), iodata(), or boolean()
erl_lint has since R13B emitted warnings whenever any of the types
arity(), bitstring(), iodata(), or boolean() were re-defined. Now
errors are emitted instead.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/stdlib/src/erl_lint.erl | 6 | ||||
-rw-r--r-- | lib/stdlib/test/erl_lint_SUITE.erl | 44 |
2 files changed, 31 insertions, 19 deletions
diff --git a/lib/stdlib/src/erl_lint.erl b/lib/stdlib/src/erl_lint.erl index 10337b279e..269e4b34cf 100644 --- a/lib/stdlib/src/erl_lint.erl +++ b/lib/stdlib/src/erl_lint.erl @@ -2790,12 +2790,6 @@ is_default_type({timeout, 0}) -> true; is_default_type({var, 1}) -> true; is_default_type(_) -> false. -%% R13 -is_newly_introduced_builtin_type({arity, 0}) -> true; -is_newly_introduced_builtin_type({bitstring, 0}) -> true; -is_newly_introduced_builtin_type({iodata, 0}) -> true; -%% R13B01 -is_newly_introduced_builtin_type({boolean, 0}) -> true; is_newly_introduced_builtin_type({Name, _}) when is_atom(Name) -> false. is_obsolete_builtin_type(TypePair) -> diff --git a/lib/stdlib/test/erl_lint_SUITE.erl b/lib/stdlib/test/erl_lint_SUITE.erl index 00a92ff4bd..5d189006a1 100644 --- a/lib/stdlib/test/erl_lint_SUITE.erl +++ b/lib/stdlib/test/erl_lint_SUITE.erl @@ -52,7 +52,7 @@ guard/1, otp_4886/1, otp_4988/1, otp_5091/1, otp_5276/1, otp_5338/1, otp_5362/1, otp_5371/1, otp_7227/1, otp_5494/1, otp_5644/1, otp_5878/1, otp_5917/1, otp_6585/1, otp_6885/1, otp_10436/1, otp_11254/1, - otp_11772/1, + otp_11772/1, otp_11771/1, export_all/1, bif_clash/1, behaviour_basic/1, behaviour_multiple/1, @@ -88,7 +88,7 @@ all() -> otp_4886, otp_4988, otp_5091, otp_5276, otp_5338, otp_5362, otp_5371, otp_7227, otp_5494, otp_5644, otp_5878, otp_5917, otp_6585, otp_6885, otp_10436, otp_11254, - otp_11772, export_all, + otp_11772, otp_11771, export_all, bif_clash, behaviour_basic, behaviour_multiple, otp_7550, otp_8051, format_warn, {group, on_load}, too_many_arguments, basic_errors, bin_syntax_errors, predef, maps]. @@ -2578,7 +2578,7 @@ otp_11254(Config) when is_list(Config) -> ok. otp_11772(doc) -> - "OTP-11772. Reintroduce warnings for redefined builtin types."; + "OTP-11772. Reintroduce errors for redefined builtin types."; otp_11772(suite) -> []; otp_11772(Config) when is_list(Config) -> Ts = <<" @@ -2592,27 +2592,45 @@ otp_11772(Config) when is_list(Config) -> -type gb_tree() :: mfa(). % Allowed since Erlang/OTP 17.0 -type digraph() :: [_]. % Allowed since Erlang/OTP 17.0 - %% \"Newly\" introduced: + -type t() :: mfa() | digraph() | gb_tree() | node(). + + -spec t() -> t(). + + t() -> + 1. + ">>, + {errors,[{7,erl_lint,{builtin_type,{node,0}}}, + {8,erl_lint,{builtin_type,{mfa,0}}}], + []} = run_test2(Config, Ts, []), + ok. + +otp_11771(doc) -> + "OTP-11771. Do not allow redefinition of the types arity(_) &c.."; +otp_11771(suite) -> []; +otp_11771(Config) when is_list(Config) -> + Ts = <<" + -module(newly). + + -compile(export_all). + + %% No longer allowed in 17.0: -type arity() :: atom(). -type bitstring() :: list(). -type iodata() :: integer(). -type boolean() :: iodata(). - -type t() :: arity() | bitstring() | iodata() | boolean() | mfa() - | digraph() | gb_tree() | node(). + -type t() :: arity() | bitstring() | iodata() | boolean(). -spec t() -> t(). t() -> 1. ">>, - {error,[{7,erl_lint,{builtin_type,{node,0}}}, - {8,erl_lint,{builtin_type,{mfa,0}}}], - [{13,erl_lint,{new_builtin_type,{arity,0}}}, - {14,erl_lint,{new_builtin_type,{bitstring,0}}}, - {15,erl_lint,{new_builtin_type,{iodata,0}}}, - {16,erl_lint,{new_builtin_type,{boolean,0}}}]} = - run_test2(Config, Ts, []), + {errors,[{7,erl_lint,{builtin_type,{arity,0}}}, + {8,erl_lint,{builtin_type,{bitstring,0}}}, + {9,erl_lint,{builtin_type,{iodata,0}}}, + {10,erl_lint,{builtin_type,{boolean,0}}}], + []} = run_test2(Config, Ts, []), ok. export_all(doc) -> |