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 @@ -26,7 +26,6 @@ generic std gap is planned here even when moq never calls it.
- [An inclusive range folded through an adaptor](/quest/m3/ts-range-fold.md) - a `RangeInclusive` folded through `map`, `filter`, or `rev` ends in core's state, and `by_ref` of one type-checks
- [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 folds, zips, flattens, and collects drop as std's do
- [Set operations](/quest/m3/ts-set-ops.md) - `union`, `intersection`, `difference`, and `symmetric_difference` of hash and B-tree sets translate
- [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
- [std accessors with no mapping](/quest/m3/ts-unmapped-accessors.md) - `VecDeque::swap_remove_*`, `HashSet::replace`, `BTreeSet::get`, `take`, and `replace`, `Vec::pop_if`, and `Arc` and `Rc::into_inner` 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
Expand All @@ -35,6 +34,7 @@ generic std gap is planned here even when moq never calls it.
- [Port the workflow guard to kixelated/quest](/quest/m3/quest-workflow-guard.md) - quest's environment guard parses YAML as this repository's does
- [A VecDeque's Debug](/quest/m3/ts-deque-debug.md) - `{:?}` of a `VecDeque` translates, writing std's list
- [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
- [An array's map](/quest/m3/ts-array-map.md) - `<[T; N]>::map` translates, calling its closure on each element in order
- [Zero-sized values made out of sight](/quest/m3/ts-zero-sized.md) - unit structs and empty arrays returned, and std adaptors of only zero-sized fields, translate
- [Array keys a collection holds](/quest/m3/ts-array-keys.md) - collections of `[T; N]` keys type-check
- [Zip's next_back in constant time](/quest/m3/ts-zip-back.md) - a reversed zip of random-access iterators skips the longer side's excess at once
16 changes: 16 additions & 0 deletions quest/m3/ts-array-map.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# [S] An array's map

## Goal

`<[T; N]>::map` translates for every element type, its closure called on each element in
order, proven by a differential test against native Rust that covers `[u8; N]` results.

## Plan

Reproduced on `955ac19f`: `[bool; 3].map(u8::from)` is refused at its span as an
unsupported call to `std::array::<impl [bool; 3]>::map`. A `[u8; N]` result is a
`Uint8Array`, as `array::from_fn`'s is.

Found by [#302](https://github.com/moq-dev/rust2/pull/302).

Public API: the translator's output.
16 changes: 0 additions & 16 deletions quest/m3/ts-set-ops.md

This file was deleted.

18 changes: 17 additions & 1 deletion ts/fixtures/lang/caller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,4 +501,20 @@ const reserves = Array.from({ length: 13 * 5 * 5 * 4 * 5 }, (_, i) =>
Uint8Array.of(reservesOp, i % 65, Math.floor(i / 65) % 5, Math.floor(i / 325) % 4, Math.floor(i / 1300)),
);

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];
/**
* `collections::set_ops` of one key against 30, which std's B-tree looks up in the larger
* rather than merging, of each key type: a key below the rest, at either end, between, and
* above. Then `Nibble`s equal to another set's but for their high bits, of hash sets as
* large as each other and one larger, where std's picks which set's to yield by size.
*/
const setOpsOp = op("collections::set_ops");
const setOps = [
...[15, 16, 17, 18, 19].flatMap((kind) => [0x20, 0x21, 0x25, 0x3e, 0x3f].map((single) => Uint8Array.of(setOpsOp, kind, single, ...Array.from({ length: 30 }, (_, i) => 0x41 + i)))),
...[
[0x01, 0x02, 0x13, 0x21, 0x32, 0x44],
[0x01, 0x02, 0x13, 0x21, 0x32, 0x44, 0x55],
[0x01, 0x02, 0x13, 0x55, 0x21, 0x32, 0x44],
].map((data) => Uint8Array.of(setOpsOp, 3, ...data)),
];

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];
4 changes: 4 additions & 0 deletions ts/fixtures/lang/expected/collections.Nibble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ export function cmp$Ord(self: Nibble, other: Nibble): rt.Ordering {
return rt.cmp(other._0 & 15, self._0 & 15);
}

export function partialCmp$PartialOrd(self: Nibble, other: Nibble): rt.Ordering | undefined {
return cmp$Ord(self, other);
}

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