fix: make Ord for slices lexicographic (elements first, then length)#9555
Conversation
|
Thank you for your contribution to the Noir language. Please do not force push to this branch after the Noir team have started review of this PR. Doing so will only delay us merging your PR as we will need to start the review process from scratch. Thanks for your understanding. |
Yes, i will do it, but if you don't mind, i will do it tomorrow |
Hi. I fixed tests and now code compiles, but i've bumped into a problem with snapshots: and to be honest i don't know why it's like that |
|
@radik878 did you run Also, the stdlib needs to be reformatted. You can cd into |
fa79905 to
a8fa180
Compare
Thanks for help, looks ready |
|
@radik878 looks like they are still outdated, maybe the branch was old and you need to I'm very sorry this PR has been blocked for as long as it has - we're working on reworking our CI to make this process easier. |
Thanks, i've bumped into such a system with snaphots for the first time so it was a bit difficult for me, at that moment all tests passed and snapshots updated, but yes, i think branch was outdated. But thanks for help really |
Automated pull of nightly from the [noir](https://github.com/noir-lang/noir) programming language, a dependency of Aztec. BEGIN_COMMIT_OVERRIDE fix: make Ord for slices lexicographic (elements first, then length) (noir-lang/noir#9555) chore(ssa): Refactor `unrolling` (noir-lang/noir#9653) chore(docs): Update dependency page's examples (noir-lang/noir#9634) fix(ssa): Constant fold Brillig calls using the SSA interpreter (noir-lang/noir#9655) chore: LICM refactors (noir-lang/noir#9642) chore: add test for trait bound on implementing type (noir-lang/noir#9652) chore: pass `DataFlowGraph` instead of `Function` as arg (noir-lang/noir#9656) feat: Group one audit tests (noir-lang/noir#9445) fix(expand): better handling of dereferences (again) (noir-lang/noir#9654) feat(mem2reg): address last known value is independent of its aliases (take three) (noir-lang/noir#9633) chore: remove handling for slice arguments to MSM (noir-lang/noir#9648) fix: validate binary operations which do not allow fields (noir-lang/noir#9649) END_COMMIT_OVERRIDE
Automated pull of nightly from the [noir](https://github.com/noir-lang/noir) programming language, a dependency of Aztec. BEGIN_COMMIT_OVERRIDE fix: make Ord for slices lexicographic (elements first, then length) (noir-lang/noir#9555) chore(ssa): Refactor `unrolling` (noir-lang/noir#9653) chore(docs): Update dependency page's examples (noir-lang/noir#9634) fix(ssa): Constant fold Brillig calls using the SSA interpreter (noir-lang/noir#9655) chore: LICM refactors (noir-lang/noir#9642) chore: add test for trait bound on implementing type (noir-lang/noir#9652) chore: pass `DataFlowGraph` instead of `Function` as arg (noir-lang/noir#9656) feat: Group one audit tests (noir-lang/noir#9445) fix(expand): better handling of dereferences (again) (noir-lang/noir#9654) feat(mem2reg): address last known value is independent of its aliases (take three) (noir-lang/noir#9633) chore: remove handling for slice arguments to MSM (noir-lang/noir#9648) fix: validate binary operations which do not allow fields (noir-lang/noir#9649) END_COMMIT_OVERRIDE
Problem: The Ord implementation for slices [T] compared lengths before elements, contradicting the function comment and common lexicographic expectations. This also diverged from arrays [T; N] and tuples, which are lexicographically ordered. Example of the surprising behavior: [2] was considered less than [1, 1, 1] purely due to length.
Changes: Updated Ord for [T] in noir_stdlib/src/cmp.nr to compare the common prefix element-wise and, only if equal, use length as a tiebreaker. Added unit test asserting [2] > [1,1,1] and [1,2] < [1,2,3].
Goal: Align behavior with documentation and established semantics across the stdlib, ensure predictable lexicographic ordering for slices, and reduce surprises for users.