From edd9607b3bea79be718b774b8c58e623b918eee2 Mon Sep 17 00:00:00 2001 From: Raimo Niskanen Date: Fri, 15 Jul 2016 16:18:06 +0200 Subject: Fix type and template errors from bugs.erlang.org: ERL-172 and ERL-187 --- lib/stdlib/doc/src/gen_statem.xml | 18 +++++++++++++----- lib/stdlib/src/gen_statem.erl | 13 +++++++------ 2 files changed, 20 insertions(+), 11 deletions(-) (limited to 'lib/stdlib') diff --git a/lib/stdlib/doc/src/gen_statem.xml b/lib/stdlib/doc/src/gen_statem.xml index c57a31fa21..ed44eef912 100644 --- a/lib/stdlib/doc/src/gen_statem.xml +++ b/lib/stdlib/doc/src/gen_statem.xml @@ -1262,9 +1262,9 @@ handle_event(_, _, State, Data) ->   Vsn = term() OldState = NewState = term() Extra = term() - Result = {NewCallbackMode,NewState,NewData} | Reason + Result = {CallbackMode,NewState,NewData} | Reason - NewCallbackMode = + CallbackMode = callback_mode() @@ -1321,11 +1321,19 @@ handle_event(_, _, State, Data) ->

If successful, the function must return the updated internal state in an - {NewCallbackMode,NewState,NewData} tuple. + {CallbackMode,NewState,NewData} tuple.

- If the function returns Reason, the ongoing - upgrade fails and rolls back to the old release.

+ If the function returns a failure Reason, the ongoing + upgrade fails and rolls back to the old release. + Note that Reason can not be a 3-tuple since that + will be regarded as a + {CallbackMode,NewState,NewData} tuple, + and that a tuple matching {ok,_} + is an invalid failure Reason. + It is recommended to use an atom as Reason since + it will be wrapped in an {error,Reason} tuple. +

This function can use erlang:throw/1 diff --git a/lib/stdlib/src/gen_statem.erl b/lib/stdlib/src/gen_statem.erl index 23bddafeed..c02e6a1a19 100644 --- a/lib/stdlib/src/gen_statem.erl +++ b/lib/stdlib/src/gen_statem.erl @@ -219,9 +219,10 @@ OldState :: state(), OldData :: data(), Extra :: term()) -> - {NewCallbackMode :: callback_mode(), + {CallbackMode :: callback_mode(), NewState :: state(), - NewData :: data()}. + NewData :: data()} | + (Reason :: term()). %% Format the callback module state in some sensible that is %% often condensed way. For StatusOption =:= 'normal' the perferred @@ -630,11 +631,11 @@ system_code_change( Result -> Result end of - {NewCallbackMode,NewState,NewData} -> - callback_mode(NewCallbackMode) orelse - error({callback_mode,NewCallbackMode}), + {CallbackMode,NewState,NewData} -> + callback_mode(CallbackMode) orelse + error({callback_mode,CallbackMode}), {ok, - S#{callback_mode := NewCallbackMode, + S#{callback_mode := CallbackMode, state := NewState, data := NewData}}; {ok,_} = Error -> -- cgit v1.2.3