From 28f7a47ab4d533cc72090484eb3a7e5713fa58bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Mon, 25 Jan 2016 15:56:59 +0100 Subject: code: Correct the types for error returns The specifications for functions that load code in the 'code' module (e.g. code:load_file/1) have some problems: * The specs claim that the functions can return {error,on_load}, but they never do. However, they can return {error,on_load_failure} if the -on_load function in a module fails. * The specs claim that the functions can return {error,native_code}, but they never do. While we are it, also extend the on_load_errors/1 test case to test that the load functions return {error,on_load_failure} when an -on_load function fails. --- lib/kernel/src/code.erl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lib/kernel/src/code.erl') diff --git a/lib/kernel/src/code.erl b/lib/kernel/src/code.erl index 7d0102d4ef..7237550786 100644 --- a/lib/kernel/src/code.erl +++ b/lib/kernel/src/code.erl @@ -77,10 +77,9 @@ %%---------------------------------------------------------------------------- -type load_error_rsn() :: 'badfile' - | 'native_code' | 'nofile' | 'not_purged' - | 'on_load' + | 'on_load_failure' | 'sticky_directory'. -type load_ret() :: {'error', What :: load_error_rsn()} | {'module', Module :: module()}. @@ -135,7 +134,7 @@ load_file(Mod) when is_atom(Mod) -> -spec ensure_loaded(Module) -> {module, Module} | {error, What} when Module :: module(), - What :: embedded | badfile | native_code | nofile | on_load. + What :: embedded | badfile | nofile | on_load_failure. ensure_loaded(Mod) when is_atom(Mod) -> call({ensure_loaded,Mod}). -- cgit v1.2.3