Skip to content

Keep parens on unary operators on the left of in - #16006

Merged
josevalim merged 1 commit into
elixir-lang:mainfrom
mandar1045:fix-formatter-unary-in
Oct 19, 2026
Merged

josevalim merged 1 commit into
elixir-lang:mainfrom
mandar1045:fix-formatter-unary-in

Conversation

@mandar1045

Copy link
Copy Markdown
Contributor

Closes #16005.

!!x in y was formatted as !(!x in y), which the parser reads as !(!(x in y)), so the result changed. Now it's formatted as !((!x) in y). Same for not, and Macro.to_string/1 is fixed too.

!x not in y doesn't have this problem, so it stays as is.

The parser rewrites !x in y as !(x in y), so !!x in y was formatted
as !(!x in y), which changes what the code does. It is now formatted
as !((!x) in y). The same applies to not.

Closes elixir-lang#16005
@josevalim
josevalim merged commit d23e799 into elixir-lang:main Oct 19, 2026
15 checks passed
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.

mix format changes what !!x in y does

2 participants