Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion quest/m3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ generic std gap is planned here even when moq never calls it.
- [A B-tree's drop order](/quest/m3/ts-btree-drop.md) - dropping a whole `BTreeMap` or `BTreeSet` drops its entries node by node, as std's does
- [Drop order in std's folds and iterators](/quest/m3/ts-drop-order.md) - the values that drop still refused in std's consumers, zips, flattens, and collects drop as std's do
- [References to byte arrays std takes](/quest/m3/ts-byte-refs-taken.md) - `extend` by references to arrays, adaptors' closures over held arrays, and a collection of both forms translate
- [Equality of std containers of unlike elements](/quest/m3/ts-eq-unlike.md) - `==` and `next_if_eq` of a `Vec<Left>` against a `&[Right]`, and of `VecDeque` against `Vec`, translate
- [Waiting: a slice object for a mutable part of other values](/quest/m3/ts-slice-object.md) - waits on a moq profile showing the `Proxy` view's traps matter, then decides on an `rt.ByteSlice`-like form
- [Port the workflow guard to kixelated/quest](/quest/m3/quest-workflow-guard.md) - quest's environment guard parses YAML as this repository's does
- [Equality through a held type's own ne](/quest/m3/ts-eq-own-ne.md) - `==` of slices of a type whose `ne` the crate overrides, and `!=` of a tuple or `Arc` of one, translate
- [std iterators' Debug](/quest/m3/ts-iter-debug.md) - `{:?}` of std's iterators translates, writing std's text, a deque's two slices included
- [LinkedList](/quest/m3/ts-linked-list.md) - `LinkedList` and its methods translate
- [A parameter read only where lowering leaves nothing](/quest/m3/ts-unread-params.md) - an instance whose lowering drops every read of a parameter marks it unused, so `tsc` accepts it
Expand Down
16 changes: 16 additions & 0 deletions quest/m3/ts-eq-own-ne.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# [S] Equality through a held type's own ne

## Goal

`==` of slices, `Vec`s, and `VecDeque`s of a crate's type whose `PartialEq` overrides `ne`,
and `!=` of a tuple or an `Arc` holding one, translate, proven by a differential test
against native Rust.

## Plan

Refused today with "through a held type's own" at the comparison's span: the runtime's
`eqSlice`, `eqTuple`, and `eqArc` compare by `eq`, where std's slices call each item's
`ne`, and a tuple's and an `Arc`'s `ne` call what they hold's. Items of unlike types
already compare by `!ne` through the crate's impl (`item_eq` in the collections
lowering); items of one type could do the same, and a tuple's or `Arc`'s `ne` could
lower by its fields' `ne`.
18 changes: 0 additions & 18 deletions quest/m3/ts-eq-unlike.md

This file was deleted.

7 changes: 5 additions & 2 deletions ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ finds any other key, a 64-bit one past 2^53 included, through its translated `Ha
`Option` orders `None` first, an `Arc` compares, orders, and hashes as what it holds,
so a map of `Arc<str>` finds a `&str`, and byte arrays, slices, and vectors order by their
bytes and then their length, and compare and hash alike whatever their form, so a map of
`Vec<u8>` finds a `&[u8]`. A collection's reference to a byte array it holds, as `keys`,
`Vec<u8>` finds a `&[u8]`. Slices, arrays, `Vec`s, and `VecDeque`s compare against each
other as std's do, by their lengths and then each pair of items in order, through the
items' own `PartialEq<U>`, and its `ne` where the crate overrides it. A collection's reference to a byte array it holds, as `keys`,
`HashSet::get`, and `retain`'s closure get one, is an `rt.ByteSlice` of its bytes, as a
`&[u8; N]` is elsewhere; a `&mut` writes where the collection holds them. A `&mut` to a value a map holds that JS copies,
such as a number, from `get_mut` or the entry API, is an `rt.Place` whose `v` reads and
Expand Down Expand Up @@ -696,7 +698,8 @@ built natively for wasm32 and run beside its translation on the same inputs by
closures that log what each
adaptor reads, `Option`'s and `Result`'s combinators, with closures that log each call,
and std's collections, over keys whose own `Hash`, `Eq`, and `Ord`
disagree with JS's, `vec![x; n]` of types whose `Clone` counts its clones, `&mut`
disagree with JS's, sequences compared across forms and item types by an `eq` and `ne`
that disagree, `vec![x; n]` of types whose `Clone` counts its clones, `&mut`
to values JS copies, of locals, fields, elements, and a map's values, passed on,
returned, kept in a struct, and captured, a `Vec`'s edits and sorts, with closures
that log what each is called with, std's `Bound`, `Reverse`, and `NonZero`, and raw
Expand Down
12 changes: 11 additions & 1 deletion ts/fixtures/lang/caller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,4 +544,14 @@ const setOps = [
const zerosOp = op("zeros::zeros");
const zeros = Array.from({ length: 7 * 4 }, (_, i) => Uint8Array.of(zerosOp, i % 7, ...Array.from({ length: Math.floor(i / 7) }, (_, b) => b)));

export const cases: Uint8Array[] = [...loops, ...durations, ...ints(), ...utf8, ...floats, ...formats, ...parsed, ...singlesCases, ...singlesFormats, ...singlesParsed, ...dyns, ...cells, ...shared, ...locks, ...onces, ...bounds, ...unsafeCells, ...edits, ...subslices, ...consumers, ...closures, ...elements, ...ranges, ...reducers, ...sliceEdits, ...drains, ...iters, ...hinted, ...peekedOthers, ...hints, ...reserves, ...setOps, ...zeros, ...floatsMulAdds, ...singlesMulAdds];
/**
* `collections::unlike_eqs` of every pair of positions where `eq` and `ne` disagree and each
* length the right side may lose, over no items, one, two, a wrapped deque's four, and nine,
* whose positions are all within it.
*/
const unlikeEqsOp = op("collections::unlike_eqs");
const unlikeEqs = [[], [5], [1, 2], [0, 7, 2, 9], [3, 3, 3, 3, 3, 3, 3, 3, 3]].flatMap((bytes) =>
Array.from({ length: 128 }, (_, kind) => Uint8Array.of(unlikeEqsOp, kind, ...bytes)),
);

export const cases: Uint8Array[] = [...loops, ...durations, ...ints(), ...utf8, ...floats, ...formats, ...parsed, ...singlesCases, ...singlesFormats, ...singlesParsed, ...dyns, ...cells, ...shared, ...locks, ...onces, ...bounds, ...unsafeCells, ...edits, ...subslices, ...consumers, ...closures, ...elements, ...ranges, ...reducers, ...sliceEdits, ...drains, ...iters, ...hinted, ...peekedOthers, ...hints, ...reserves, ...setOps, ...zeros, ...floatsMulAdds, ...singlesMulAdds, ...unlikeEqs];
35 changes: 35 additions & 0 deletions ts/fixtures/lang/expected/collections.Left.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Generated by rust2-ts. Do not edit.

import * as rt from "./rt.ts";
import type * as Right from "./collections.Right.ts";

/**
* An item that equals a `Right` of the same remainder by 4, but whose `ne` sees the
* remainder by 3, so what `!=` finds tells which std calls. Each call adds to the log,
* in order.
*/
export interface Left {
_0: rt.u16;
_1: rt.Cell<rt.u16>;
}

export function log(self: Left, by: rt.u16): void {
rt.cellSet(self._1, rt.u16WrappingAdd(rt.u16WrappingMul(self._1.v, 31), self._0 ^ by));
}

export function ne$PartialEq_Right(self: Left, other: Right.Right): boolean {
log(self, 512);
return rt.u16Rem(self._0, 3) !== rt.u16Rem(other._0, 3);
}

export function eq$PartialEq_Right(self: Left, other: Right.Right): boolean {
log(self, 2048);
return rt.u16Rem(self._0, 5) === rt.u16Rem(other._0, 5);
}

export function eq$PartialEq_Left(self: Left, other: Left): boolean {
log(self, 4096);
return rt.u16Rem(self._0, 2) === rt.u16Rem(other._0, 2);
}

//# sourceMappingURL=collections.Left.ts.map
18 changes: 18 additions & 0 deletions ts/fixtures/lang/expected/collections.Odd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Generated by rust2-ts. Do not edit.

import * as rt from "./rt.ts";
import type * as Right from "./collections.Right.ts";

/**
* An item only a reference to compares, by the crate's impl of two references, which
* std's of references would otherwise forward from.
*/
export interface Odd {
_0: rt.u16;
}

export function eq$PartialEq_Right(self: Odd, other: Right.Right): boolean {
return rt.u16Rem(self._0, 2) === rt.u16Rem(other._0, 2);
}

//# sourceMappingURL=collections.Odd.ts.map
15 changes: 15 additions & 0 deletions ts/fixtures/lang/expected/collections.Right.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Generated by rust2-ts. Do not edit.

import * as rt from "./rt.ts";
import * as Left from "./collections.Left.ts";

export interface Right {
_0: rt.u16;
}

export function eq$PartialEq_Left(self: Right, other: Left.Left): boolean {
Left.log(other, 1024);
return rt.u16Rem(self._0, 4) === rt.u16Rem(other._0, 4);
}

//# sourceMappingURL=collections.Right.ts.map
Loading