Repository navigation
feat(emit): two tuples or two arrays order by their parts - #366
Merged
Merged
Conversation
The types chapter gives an unnamed form `Ord` when every part has it,
and `(1, 2) < (1, 3)` was E3044. A tuple and an array now order
lexicographically: the first part that differs decides, and nothing
after it is read.
- the four operators come from one `less`, as `Ord`'s do, so `a <= b`
is `not (b < a)` and each operand is evaluated once
- the operands are bound and held the way `==` binds them, through
the same lowering, which now picks its test by operator
- a part orders when it is an integer of any width, a `str`, a type
with an `Ord`, or a tuple or array whose parts do; a `float` does
not, a NaN breaking a total order
- one with a part that does not is refused for that part, under E3044
A list, a map and a set still have no order.
Closes #360.
Bumps test-data for codegen/tuple_order.
Three reject cases — a `float` part, a part with `Eq` and no `Ord`,
and a part found inside an array of tuples — each holding the part's
name. A mem-check case holds what an ordering gives back over owned
tuples, a declared part and arrays: shown red with the left operand's
give-back removed.
The rule's `Ord` half is built; the paragraph after it says how a
tuple orders and what a part without an order is refused as.
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.
Closes #360.
What
Two tuples, or two arrays, order with
<<=>>=by their parts, asdocs/core/types.mdalready said:the first part that differs decides, and nothing after it is read.
Decisions made here
[not yet]. The issue allowed either; the==half was built in two containers compare with == and != #295 with the samebinding and holding, so the ordering reuses that lowering and only the test differs.
less, asOrd's do (a <= bisnot (b < a)), so each operand isevaluated once. A part is asked
<both ways to tell "differs" without asking==too.str, a type with anOrd, or a tuple / array whoseparts do. A
floatdoes not (a NaN breaks a total order, which is why it sits outOrd), and neither does abool.E3044— the same rule as two operands that arenot numbers, so one report site with a different subject (
error-codes-checkholds one site per code).Verified
seed-gaps refuse reject mem-check oracle corpus sanitize-corpus mem-peak examples docs-mirror docs-links
docs-zerg docs-refused docs-repeat marker-codes chapter-codes deviation-check refusal-cites method-gaps gates
treesitter dead-code stdlib-test compiler-test check-equal reject-fuzz fmt-corpus behaviour conformance
productions suites desugar.
rejectandmem-checkalso under/bin/bash.mem-checkcase was red with the left operand's give-back removed for an ordering (780 per round),green after.
Found on the way, not fixed
docs/core/specs.mdsaysimpl Ord for Pis E3013 no spec namedOrd; the corpus case writesimpl Ord for Vand it builds and dispatches. That[not yet]looks stale forOrd.sortor aT: Ordbound over a tuple was not measured.Not verified
make testas one board was not run.🤖 Generated with Claude Code
https://claude.ai/code/session_01N8jd1oK2orM6diHxhvWhC7