Skip to content

Basic coerce optimization - #1798

Merged
Bike merged 7 commits into
mainfrom
basic-coerce-optimization
Jun 30, 2026
Merged

Basic coerce optimization#1798
Bike merged 7 commits into
mainfrom
basic-coerce-optimization

Conversation

@Bike

@Bike Bike commented Jun 29, 2026

Copy link
Copy Markdown
Member

Optimizes out (coerce (the thing x) 'thing), since I noticed Khazern does that a lot. Also silences the "can't coerce to REAL" type warnings until we have sophisticated enough machinery to note genuinely invalid coercions.

Also special cases (subtypep foo 't) because the Baker subtypep is really bad (conformance-breakingly, even) on cons types.

Bike added 7 commits June 29, 2026 11:16
it's triggering a _lot_ on (coerce x 'real) which khazern
generates for e.g. maximize clauses. That's weird but totally valid
so the warning is spurious. I checked SBCL and it has some pretty
complex logic for when to warn, mostly based on when it can confirm
the coercion is impossible because the argument is definitely not
of the result type.
our subtypep gives up and dies on nontrivial cons types, so for
example, a transform specialized on (T T) failed because
(subtypep 'type-specifier 't) gave NIL NIL. No good! Has that
typep transform even been firing? I guess not. Really need better
explainability as well
broken cons types are annoying. I want everything to be a known
subtype of T at minimum
CLHS says this check is always first, by my reading, so this
reduction is valid even with the weird COMPLEX stuff.

Khazern generates a lot of (coerce foo 'real) for MAXIMIZE clauses
so it's good to take care of this obvious stuff.
i don't know why i thought FLOAT would mess with floats?
@Bike
Bike merged commit 7a3b694 into main Jun 30, 2026
16 of 18 checks passed
@Bike
Bike deleted the basic-coerce-optimization branch June 30, 2026 04:39
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.

1 participant