`non_empty_list/2` tail absorption unexpected behavior · Issue #15641 · elixir-lang/elixir · GitHub
Skip to content

non_empty_list/2 tail absorption unexpected behavior #15641

Open

Description

@lukaszsamson

Existing issue

  • I have searched existing issues and could not find a duplicate.

Elixir and Erlang/OTP versions

Erlang/OTP 28 [erts-16.4.0.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]

Interactive Elixir (1.21.0-dev)

Operating system

any

Current behavior

I understand that type widening and tail absorption is deliberate but it leads to surprising results. Here I construct a type [none(), (...), | term()] which is not inhabited by any value. none() gets overapproximated to term()

Repro:

t = non_empty_list(none(), term())
empty?(t) # false, I'd expect true
to_quoted_string(t) # "non_empty_list(term(), term())"
equal?(non_empty_list(none(), term()), non_empty_list(term(), term())) # true

Expected behavior

I don't know. Either accepted overapproximation or improved precision

Activity

  1. gldubc commented on Jul 22, 2026

    @gldubc
    Member

    I agree it's not ideal. I'm working on a new constructor for lists which won't have this issue.

  2. added theissue type on Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions