Stage 2 — Conversions

Copy Markdown View Source

Verdict on this Mac: PASS. Linux: PENDING.

Mojoler.Term is the checked surface. Bad arguments use enif_make_badarg. Domain failures are {:error, reason} with a fixed atom, created by enif_make_atom of a literal. User bytes never become an atom.

ModeWhat happensCopy of the payload
echo_i64 and the other widthsRange is whatever enif_get_* accepts. Outside that, ArgumentError.none
add_i64{:ok, sum} or {:error, :overflow}none
echo_f64Integers are not coerced. This OTP raises ArithmeticError on 0.0 / 0.0, so a NaN term was not constructed. The NIF still returns {:error, :nan} if n != n.none
echo_atomOnly :ok, :error, :nil, true, falsenone
copy_binary{:ok, binary, byte_size}. Empty, NUL, UTF-8, and sub-binaries match Elixir. <<1::7>> is {:error, :not_binary}.one new binary
borrow_stableTwo inspects. {:ok, size, 1} when the data pointers match. The pointer is not returned.none
fill_outputenif_make_new_binary, then the bytes are written in that buffer.none before the return binary
text_lenUTF-8 check, no normalizationnone
tuple_sumArity 2none
list_sumProper lists, length cap 64, depth 1 (a nested list is :bad_element)none
map_nRequires integer n. Extra keys are dropped. Missing key is :missing.the returned one-key map

calloc descriptors are released with free. enif_alloc scratch used for tuples is released with enif_free. Tests compare against Elixir, not against a second call of the same NIF alone.