Closed OTP-Maintainer closed 3 years ago
hans
said:
The no_return() is possible, it can be thrown from the nif C-function:
{code:java}
1> crypto:crypto_init(aes_128_ctr, <<>>, <<>>, true).
** exception error: {badarg,{"api_ng.c",143},"Bad key size"}
in function crypto:ng_crypto_init_nif/5
called as crypto:ng_crypto_init_nif(aes_128_ctr,<<>>,<<>>,true,
undefined)
2>
{code}
hans
said:
Thanks for the report! Will be released in OTP-23.1
kostis
said:
`no_return()` does not mean what you think it means.
`no_return()` means that the function does not return any value ever, not that it throws some exception.
For example, the `lists:nth/2` function, or for that matter pretty much any function in Erlang, also throws an exception when called with some combination of arguments that the function does not handle:
{code:java}
1> lists:nth(2, []).
** exception error: no function clause matching lists:nth(2,[]) (lists.erl, line 170)
{code}
but it's (correctly) spec-ed as returning `term()`, not `term() | no_return()`.
Original reporter:
kostis
Affected version:OTP-23.0
Fixed in version:OTP-23.1
Component:crypto
Migrated from: https://bugs.erlang.org/browse/ERL-1257