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 @@ -33,5 +33,5 @@ generic std gap is planned here even when moq never calls it.
- [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
- [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
- [Unbounded ranges as iterators adaptors take](/quest/m3/ts-range-from-iter.md) - `iter.zip(0..)` and other adaptors taking a `start..` type-check
15 changes: 0 additions & 15 deletions quest/m3/ts-array-keys.md

This file was deleted.

16 changes: 16 additions & 0 deletions quest/m3/ts-range-from-iter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# [S] Unbounded ranges as iterators adaptors take

## Goal

An unbounded `start..` that an adaptor takes as its `IntoIterator`, as `iter.zip(0..)`
does, translates to an iterator `tsc` accepts, proven by a differential test against
native Rust, including where `start` reaches its type's maximum.

## Plan

Found by `keys::arrays` in the lang fixture: `firsts.iter().zip(0..)` translates to
`rt.iterZip(rt.iterSlice(firsts), { start: 0 })`, which `tsc` rejects, since the range's
struct reaches `iterZip` in place of an `rt.Iter`. Audit every adaptor that takes an
`IntoIterator` (`zip`, `chain`, `extend`, `eq`, `cmp`) for the same.

Public API: the translator's output.
7 changes: 4 additions & 3 deletions ts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,10 @@ number, string, or boolean in a JS `Map`, which compares those as Rust's `Eq` do
finds any other key, a 64-bit one past 2^53 included, through its translated `Hash` and
`Eq`; a B-tree orders every key by its translated `Ord`. std's impls are the runtime's: an
`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]`. Slices, arrays, `Vec`s, and `VecDeque`s compare against each
so a map of `Arc<str>` finds a `&str`, and arrays, slices, and vectors, of bytes or of
other elements, order by their elements and then their length, and compare and hash alike
whatever their form, so a map of `Vec<u8>` finds a `&[u8]` and one of `[u16; 2]` a `&[u16]`.
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
Expand Down
57 changes: 57 additions & 0 deletions ts/fixtures/lang/expected/core/bool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import * as rt from "../rt.ts";
import * as Made from "../defaults.Made.ts";
import type * as Hop from "../keys.Hop.ts";
import type * as Way from "../keys.Way.ts";
import type * as Void from "../shapes.Void.ts";

Expand Down Expand Up @@ -124,6 +125,13 @@ export function then$1j955kq(self: boolean, _: () => Made.Made): Made.Made | und
return Made.default$Default();
}

export function then$1c9ust9(self: boolean, f: () => Hop.Hop[]): Hop.Hop[] | undefined {
if (!self) {
return undefined;
}
return f();
}

export function then$1t2ieki(self: boolean, f: () => [rt.u64 | undefined, Made.Made]): [rt.u64 | undefined, Made.Made] | undefined {
if (!self) {
return undefined;
Expand All @@ -138,6 +146,13 @@ export function then$16ew6vr(self: boolean, f: () => rt.u8 | undefined): rt.u8 |
return f();
}

export function then$0b2eeh4(self: boolean, f: () => Array<rt.u8 | undefined>): Array<rt.u8 | undefined> | undefined {
if (!self) {
return undefined;
}
return f();
}

export function then$0afp4no(self: boolean, f: () => rt.Result<rt.u8, rt.ParseIntError>): rt.Result<rt.u8, rt.ParseIntError> | undefined {
if (!self) {
return undefined;
Expand Down Expand Up @@ -166,13 +181,55 @@ export function then$0ozmvid(self: boolean, f: () => rt.ByteVec): rt.ByteVec | u
return f();
}

export function then$1ghn4qd(self: boolean, f: () => boolean[]): boolean[] | undefined {
if (!self) {
return undefined;
}
return f();
}

export function then$1dhbcvy(self: boolean, f: () => rt.char[]): rt.char[] | undefined {
if (!self) {
return undefined;
}
return f();
}

export function then$1nf265w(self: boolean, f: () => rt.i32[]): rt.i32[] | undefined {
if (!self) {
return undefined;
}
return f();
}

export function then$0havnzo(self: boolean, f: () => string): string | undefined {
if (!self) {
return undefined;
}
return f();
}

export function then$0l07w38(self: boolean, f: () => rt.u16[]): rt.u16[] | undefined {
if (!self) {
return undefined;
}
return f();
}

export function then$0l8o6jo(self: boolean, f: () => rt.u32[]): rt.u32[] | undefined {
if (!self) {
return undefined;
}
return f();
}

export function then$0uovwq9(self: boolean, f: () => rt.u64[]): rt.u64[] | undefined {
if (!self) {
return undefined;
}
return f();
}

export function then$1btzga3(self: boolean, f: () => rt.u8): rt.u8 | undefined {
if (!self) {
return undefined;
Expand Down
114 changes: 109 additions & 5 deletions ts/fixtures/lang/expected/core/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import type * as Twin from "../counts.Twin.ts";
import * as Made from "../defaults.Made.ts";
import type * as Shape from "../dyns.Shape.ts";
import * as Named from "../edits.Named.ts";
import type * as Big from "../hints.Big.ts";
import type * as Unit from "../hints.Unit.ts";
import type * as Quarter from "../iters.Quarter.ts";
import type * as Tilt from "../iters.Tilt.ts";
Expand Down Expand Up @@ -575,6 +574,20 @@ export function mapOr$04khdaj(self: Hop.Hop | undefined, default_: rt.u64, f: (a
return f(self);
}

export function mapOr$0rtxftk(self: Hop.Hop[] | undefined, default_: rt.u8, f: (a0: Hop.Hop[]) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$0spovx0(self: [Hop.Hop[], rt.u8] | undefined, default_: rt.u8, f: (a0: [Hop.Hop[], rt.u8]) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$14aggam(self: orders_Item.Item | undefined, default_: rt.u8, f: (a0: orders_Item.Item) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
Expand Down Expand Up @@ -645,6 +658,20 @@ export function mapOr$1xztl8h(self: rt.u8 | undefined | rt.None, default_: rt.u8
return f(self);
}

export function mapOr$1bumeih(self: Array<rt.u8 | undefined> | undefined, default_: rt.u8, f: (a0: Array<rt.u8 | undefined>) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$187k0x1(self: [Array<rt.u8 | undefined>, rt.u8] | undefined, default_: rt.u8, f: (a0: [Array<rt.u8 | undefined>, rt.u8]) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$1e4a1e0(self: rt.Ordering | undefined, default_: rt.u8, f: (a0: rt.Ordering) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
Expand Down Expand Up @@ -743,28 +770,28 @@ export function mapOr$1unqgn7(self: rt.Arc<counts_Noisy.Noisy>[] | undefined, de
return f(self);
}

export function mapOr$1cxlmys(self: Big.Big[] | undefined, default_: rt.usize, f: (a0: Big.Big[]) => rt.usize): rt.usize {
export function mapOr$0r2th8w(self: Unit.Unit[] | undefined, default_: rt.usize, f: (a0: Unit.Unit[]) => rt.usize): rt.usize {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$0r2th8w(self: Unit.Unit[] | undefined, default_: rt.usize, f: (a0: Unit.Unit[]) => rt.usize): rt.usize {
export function mapOr$1kiffmd(self: rt.u16[] | undefined, default_: rt.u8, f: (a0: rt.u16[]) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$1kiffmd(self: rt.u16[] | undefined, default_: rt.u8, f: (a0: rt.u16[]) => rt.u8): rt.u8 {
export function mapOr$1umcrqz(self: rt.u32[] | undefined, default_: rt.usize, f: (a0: rt.u32[]) => rt.usize): rt.usize {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$1umcrqz(self: rt.u32[] | undefined, default_: rt.usize, f: (a0: rt.u32[]) => rt.usize): rt.usize {
export function mapOr$0ow0wo0(self: rt.u32[][] | undefined, default_: rt.usize, f: (a0: rt.u32[][]) => rt.usize): rt.usize {
if (self === undefined) {
return default_;
}
Expand Down Expand Up @@ -799,13 +826,55 @@ export function mapOr$08xwngs(self: rt.ByteVec | undefined, default_: rt.usize,
return f(self);
}

export function mapOr$0qqhf4e(self: boolean[] | undefined, default_: rt.u8, f: (a0: boolean[]) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$13q9j26(self: [boolean[], rt.u8] | undefined, default_: rt.u8, f: (a0: [boolean[], rt.u8]) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$0atjiti(self: rt.char | undefined, default_: rt.u32, _: (a0: rt.char) => rt.u32): rt.u32 {
if (self === undefined) {
return default_;
}
return self as rt.u32;
}

export function mapOr$141aobk(self: rt.char[] | undefined, default_: rt.u8, f: (a0: rt.char[]) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$1afbbm4(self: [rt.char[], rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.char[], rt.u8]) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$17y4wkx(self: rt.i32[] | undefined, default_: rt.u8, f: (a0: rt.i32[]) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$03mkmku(self: [rt.i32[], rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.i32[], rt.u8]) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$1llunel(self: rt.u16 | undefined, default_: rt.u16, f: (a0: rt.u16) => rt.u16): rt.u16 {
if (self === undefined) {
return default_;
Expand All @@ -820,20 +889,55 @@ export function mapOr$099335t(self: rt.u16 | undefined, default_: rt.u8, f: (a0:
return f(self);
}

export function mapOr$0iyypgq(self: [rt.u16[], rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.u16[], rt.u8]) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$1giiemz(self: rt.Place<rt.u32> | undefined, default_: rt.u32, f: (a0: rt.Place<rt.u32>) => rt.u32): rt.u32 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$1h1mlmc(self: rt.u32[] | undefined, default_: rt.u8, f: (a0: rt.u32[]) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$1xwgm12(self: [rt.u32[], rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.u32[], rt.u8]) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$0ucbp7g(self: [rt.u64, rt.u64] | undefined, default_: rt.u8, f: (a0: [rt.u64, rt.u64]) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$0nlcxqx(self: rt.u64[] | undefined, default_: rt.u8, f: (a0: rt.u64[]) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$0vfd25u(self: [rt.u64[], rt.u8] | undefined, default_: rt.u8, f: (a0: [rt.u64[], rt.u8]) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
}
return f(self);
}

export function mapOr$1wxcg5q(self: [rt.u8, rt.Arc<rt.u8>] | undefined, default_: rt.u8, f: (a0: [rt.u8, rt.Arc<rt.u8>]) => rt.u8): rt.u8 {
if (self === undefined) {
return default_;
Expand Down
4 changes: 2 additions & 2 deletions ts/fixtures/lang/expected/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { hints, reserves } from "./hints.ts";
import { holds } from "./holds.ts";
import { u8Op, u16Op, u32Op, u64Op, u128Op, usizeOp, i8Op, i16Op, i32Op, i64Op, i128Op, isizeOp, i8Neg, i16Neg, i32Neg, i64Neg, i128Neg, isizeNeg, cast as ints_cast, convert, parses as ints_parses, widenings } from "./ints.ts";
import { adaptors, consumers, reducers, peekedOthers, skips, ranked, ranges, options, own, values as iters_values, returned } from "./iters.ts";
import { keys, overrides, bytes as keys_bytes, lentKeys, lentValues } from "./keys.ts";
import { keys, overrides, bytes as keys_bytes, lentKeys, lentValues, arrays } from "./keys.ts";
import { locals } from "./locals.ts";
import { locks, relock, rwlocks } from "./locks.ts";
import { nested } from "./nested.ts";
Expand Down Expand Up @@ -194,7 +194,7 @@ export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec)
lent(data70, out71);
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["floats::mul_adds", mulAdds as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["singles::mul_adds", singles_mulAdds as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["fmt::collections", (_2171: rt.u8, data71: rt.ByteSlice, out72: rt.ByteVec): undefined => {
collections(data71, out72);
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::unlike_eqs", unlikeEqs as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["zeros::impls", impls as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["zeros::keys", zeros_keys as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]];
}] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["collections::unlike_eqs", unlikeEqs as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["zeros::impls", impls as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["zeros::keys", zeros_keys as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined], ["keys::arrays", arrays as (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => undefined]];
}

/** Run one case. */
Expand Down
31 changes: 0 additions & 31 deletions ts/fixtures/lang/expected/hints.Big.ts

This file was deleted.

Loading