fix: avoid deprecated implicit Compare promotion for MoonBit v0.10.9 - #52
Merged
Conversation
`derive(Compare)` generates a trait impl, and v0.10.9 deprecated the
implicit promotion of derived trait methods to type methods. The internal
comparison helpers called `self.compare(other)`, which relied on exactly
that promotion, so the build emitted 18 `[0020]` deprecation warnings
across `Date`, `Time`, and `DateTime` (`is_before`, `is_after`, `min`,
`max`, and both `clamp` bounds on each). Note `moon check` stayed silent;
only the `moon test` build path reported them.
Every site had the shape `self.compare(x) OP 0`, so use the comparison
operators directly: they desugar through the `Compare` impl without any
method promotion, and read better than the explicit `Compare::compare`
call the compiler suggests.
Deliberately not adding `extend T with Compare::{compare, ..}`: the
generated interface exports `derive(Compare, ...)` and no `compare`
method, so an `extend` declaration would widen the public API rather
than fix the deprecation. `src/pkg.generated.mbti` is byte-identical
after `moon info`; 297/297 tests pass on wasm, wasm-gc, js, and native.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
derive(Compare)generates a trait impl, and v0.10.9 deprecated the implicit promotion of derived trait methods to type methods. The internal comparison helpers calledself.compare(other), which relied on exactly that promotion, so the build emitted 18[0020]deprecation warnings acrossDate,Time, andDateTime—is_before,is_after,min,max, and bothclampbounds on each.Note that
moon checkstayed silent; only themoon testbuild path reported them.Change
Every site had the shape
self.compare(x) OP 0, so use the comparison operators directly:They desugar through the
Compareimpl without any method promotion, and read better than the explicitCompare::compare(self, other) OP 0form the compiler suggests.Deliberately not adding
extend T with Compare::{compare, ..}: the generated interface exportsderive(Compare, ...)and nocomparemethod, so anextenddeclaration would widen the public API rather than fix the deprecation.Verification
src/pkg.generated.mbtibyte-identical aftermoon info— no visible change for downstream users.moon test --target allbuild: 0.moon fmtproduced no further changes.Checked under moonc
v0.10.10+f8a486b6f(upgraded fromv0.10.7+bc794d341). No other surface in the 0.10.7 -> 0.10.10 jump touches this repo: nodefer/errdefer, nofragile_catch_allorguard_inexhaustivehits,StringBuilder()already the constructor form, and no use of@immut/hashmap/hashset/vector,bigint,@fs,Iter2Show,from_sorted_array, orlexmatch/lexscan.