You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Atom literal types are not enforced: :banana is accepted as :ok | :error #641
docs/types.md (Atoms) says an atom can be used as a type that accepts only that value, and that a union of atoms restricts a value to that set. The checker does not enforce it.
Repro
let status: :ok | :error = :banana
main do
IO.printLine("${status}")
end
Actual: accepted; prints :banana.
Expected: Type mismatch: expected :ok | :error, got :banana.
Cause
An atom literal is inferred as a nameless Atom (src/semantic/typechecker_expr.cxx:530), and the name an atom type was written with is kept for display only: every comparison ignores it (src/semantic/types.hxx:23-28).
A fix has to keep the literal name on the inferred type and then drop it where the value stops being that literal (an unannotated let, a type variable being bound, joined branches), or programs that reassign or collect different atoms would start failing.
Reproduced on kex 0.4.0-rc.3 (266b7a60) with the type checker on.
Activity