is/2: type_error(evaluable, _) culprit for an atom should be Atom/0, not the bare atom #36
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
is/2raises atype_error(evaluable, Culprit)whoseCulpritis a bare atom when an atom is used as an arithmetic expression, instead of the ISO-mandated predicate indicatorAtom/0. The compound case is already correct (foo(1)→foo/1), so this is an inconsistency in the atom path only.ISO requirement
ISO 13211-1 §7.8.9 / §8.6 (
is/2): when a sub-term of the expression is not evaluable, the error iswhere
Indicatoris a predicate indicatorName/Arity. For an atomfoo(arity 0), the indicator isfoo/0— not the atomfoo.Reproduction
Expected vs actual
X is foofoo/0foo❌X is foo(1)foo/1foo/1✅Likely locus
In
crates/runtime/src/builtins/arith.rs, the non-evaluable atom path (≈ line 121) passes the bare atom term as thetype_error(evaluable, _)culprit, whereas the unknown-arithmetic-operator path (≈ line 220) correctly constructsName/Arity. The atom path should likewise build the indicatorAtom/0(functor/with the atom and integer0) rather than passing the atom itself.Impact
Low severity — catchers that match the culprit slot are nonstandard practice, and well-written code matches
type_error(evaluable, _). But it's a genuine conformance gap: portable code that inspects the indicator (e.g. an error reporter that printsName/Arity) gets a malformed term for the arity-0 case, and the same predicate produces two different shapes (foovsfoo/1) depending only on the culprit's arity.Found while authoring the loglings exceptions chapter; all loglings exercises deliberately match
type_error(evaluable, _)so the corpus is unaffected.#37