Skip to content

Do not skip arity checks for functions in negation form - #16123

Merged
josevalim merged 4 commits into
mainfrom
jv-fun-negation
Nov 21, 2026
Merged

josevalim merged 4 commits into
mainfrom
jv-fun-negation

Conversation

@josevalim

@josevalim josevalim commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Closes #16103.
Closes #16104.

@josevalim
josevalim requested a review from gldubc November 12, 2026 15:55
@josevalim josevalim changed the title Do not skip arity checks for functions in negation form, closes #16103 Do not skip arity checks for functions in negation form Nov 12, 2026

@gldubc gldubc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes are all good!

One thing to fix: the hint with :mixed_arity. In general this correctly says that the function has multiple arities, so you should select it with a guard function(_, n).

But it might be that the arity you wanted is actually not in the function.

For instance take type fun() and not (fun(1) or fun(2)), which appears as {:negation, [1, 2]}.

Trying to call this with arity 1 will tell you to refine with a guard is_function_, 1), which does not work.

Si the :mixed_arity hint should only be shown, in the :negative case, if the arity n of the argument is not in the negative arities list.

@josevalim
josevalim merged commit d8f5192 into main Nov 21, 2026
26 checks passed
@josevalim
josevalim deleted the jv-fun-negation branch November 21, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants