Skip to content

Conversation

@gus-massa
Copy link
Contributor

cptypes was just copying the type from x to (- x). Use predicate-close/plus to get a closed set that includes the result.

Is it possible to try to get a more precise type for the result, like in the (+ x) case, but I think it's better to fix the bug now and improve the code later.

Thanks to @wtakuo for the bug report in Racket #5408 and @mflatt for minimizing it to code in Chez Scheme.

cptypes was just copying the type from x to (- x).
Use predicate-close/plus to get a closed set
that includes the result.
Copy link
Contributor

@burgerrg burgerrg left a comment

Choose a reason for hiding this comment

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

Thank you for this fix!

The type recovery pass has improved support for \scheme{exact}, \scheme{inexact},
and similar functions.

Fix wrong type of \scheme{(- x)}, in particular when \scheme{x} is \scheme{(most-negative-fixnum)}.
Copy link
Contributor

Choose a reason for hiding this comment

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

A bug that incorrectly determined the type of \scheme{(- x)} when \scheme{x} is \scheme{(most-negative-fixnum)} was fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added "in particular", because it can get the wrong type in other cases. (most-negative-fixnum) is the easiest one.

After a while, I got this:

> (expand/optimize '(lambda (x) (when (or (not x) (eqv? x 4))
                                  (let ([y (- x)]) (list y y)))))

the result is (list 4 4) instead of (list -4 -4).

Copy link
Contributor

Choose a reason for hiding this comment

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

Good find!

A bug that incorrectly determined the type of \scheme{(- x)} in some cases has been fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What about this?

A bug that in some cases incorrectly determined the type of \scheme{(- x)} has been fixed.

or just

A bug that incorrectly determined the type of \scheme{(- x)} has been fixed.

@burgerrg burgerrg merged commit 7ca54f6 into cisco:main Dec 22, 2025
16 checks passed
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