Skip to content

Conversation

@lue-bird
Copy link
Collaborator

@lue-bird lue-bird commented Dec 28, 2025

abs 3
--> 3

abs (abs n)
--> abs n

abs -n
--> abs n

max n -n
--> abs n

min n -n
--> -(abs n)

including composition where possible.

replaceBySubExpressionFix checkInfo.parentRange checkInfo.firstArg

else
[ Fix.replaceRangeBy checkInfo.parentRange
Copy link
Owner

Choose a reason for hiding this comment

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

Instead of calling AstHelpers.getUncomputedNumberValue, couldn't we try to find the negation node, and only remove the - sign(s)? That way we could preserve the style in all cases.

Copy link
Collaborator Author

@lue-bird lue-bird Dec 28, 2025

Choose a reason for hiding this comment

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

I think, since that check is after the "abs on negated" checks, any input argument should never be negated in practice (basically the else should be dead code).

@jfmengels jfmengels merged commit 734fa06 into jfmengels:main Dec 28, 2025
2 checks passed
@lue-bird lue-bird deleted the basics-abs-siplifications branch December 28, 2025 21:55
@jfmengels
Copy link
Owner

Thanks 😊

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants