Skip to content

Align Access.filter/1 spec with its truthy semantics#15550

Merged
josevalim merged 1 commit into
elixir-lang:mainfrom
nseaSeb:fix-access-filter-spec
Jul 8, 2026
Merged

Align Access.filter/1 spec with its truthy semantics#15550
josevalim merged 1 commit into
elixir-lang:mainfrom
nseaSeb:fix-access-filter-spec

Conversation

@nseaSeb

@nseaSeb nseaSeb commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Access.filter/1 treats the predicate's return value as truthy/falsy, not strictly boolean: the :get path uses it as a comprehension filter (for elem <- data, func.(elem)) and the :get_and_update path uses if func.(head). The spec (term -> boolean) was therefore narrower than what the code accepts. Every sibling accessor already uses as_boolean(term)Access.find/1, Map.filter/2, Keyword.filter/2, MapSet.filter/2 — so this aligns Access.filter/1 with that convention.

Assisted-by: Claude Code:claude-opus-4-8

`Access.filter/1` treats the predicate's return value as truthy/falsy,
not strictly boolean: the `:get` path uses it as a comprehension filter
(`for elem <- data, func.(elem)`) and the `:get_and_update` path uses
`if func.(head)`. The spec `(term -> boolean)` was therefore narrower
than what the code accepts. Every sibling accessor already uses
`as_boolean(term)` — `Access.find/1`, `Map.filter/2`, `Keyword.filter/2`,
`MapSet.filter/2` — so this aligns `Access.filter/1` with that convention.

Assisted-by: Claude Code:claude-opus-4-8
Signed-off-by: nseaSeb <nseaprotector@gmail.com>
@josevalim josevalim merged commit 9c83ece into elixir-lang:main Jul 8, 2026
15 checks passed
@josevalim

Copy link
Copy Markdown
Member

💚 💙 💜 💛 ❤️

@nseaSeb

nseaSeb commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

It makes my day, Thanks a lot @josevalim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants