From ded3488a38d4a92e450742dfdb99426b22f05dca Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Thu, 29 Oct 2026 19:44:09 -0700 Subject: [PATCH 1/2] chore(quest): claim quest/m3/ts-fmt-wrappers.md Quest-Claim: d7da809b091a91de From 44a7bef667bbe46f8d4a130f327d8e0ed9e1edfb Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Thu, 29 Oct 2026 19:57:37 -0700 Subject: [PATCH 2/2] feat(ts): format Arc as what it holds, and std's ranges with Debug `Arc` and `Rc` write their value with `Display` and `Debug` under the same formatter, and each std range writes its bounds with the range's options, plus ` (exhausted)` once iteration exhausts an inclusive one. A `..` constant translates to `undefined`, as a `RangeFull` value is. Co-Authored-By: Claude Opus 5.5 --- quest/m3/README.md | 1 - quest/m3/ts-fmt-wrappers.md | 16 ---- ts/fixtures/lang/expected/fmt.Clip.ts | 19 ++++ ts/fixtures/lang/expected/fmt.Shared.ts | 33 +++++++ ts/fixtures/lang/expected/fmt.ts | 117 +++++++++++++++++++++++- ts/fixtures/lang/expected/harness.ts | 100 ++++++++++---------- ts/fixtures/lang/expected/lib.ts | 5 + ts/fixtures/lang/src/fmt.rs | 104 +++++++++++++++++++++ ts/fixtures/lang/src/harness.rs | 1 + ts/runtime/rt.ts | 42 +++++++++ ts/src/lower/consts.rs | 1 + ts/src/lower/fmt.rs | 19 ++++ 12 files changed, 391 insertions(+), 67 deletions(-) delete mode 100644 quest/m3/ts-fmt-wrappers.md create mode 100644 ts/fixtures/lang/expected/fmt.Clip.ts create mode 100644 ts/fixtures/lang/expected/fmt.Shared.ts diff --git a/quest/m3/README.md b/quest/m3/README.md index 0d20fa142..216da320d 100644 --- a/quest/m3/README.md +++ b/quest/m3/README.md @@ -27,7 +27,6 @@ generic std gap is planned here even when moq never calls it. - [Checks on the differential harnesses](/quest/m3/ts-harness.md) - step lists that drift, literal op bytes, and `refs`'s coverage fail a test or get cases - [Ordering in std](/quest/m3/ts-ordering.md) - `cmp::max`/`min`, `is_sorted`, and `BinaryHeap`, and #173's cost on integers measured - [Arc's unique-access functions](/quest/m3/ts-arc-mut.md) - `Arc::get_mut`, `make_mut`, `pin`, and `as_deref` of an `Option` translate -- [Debug and Display of Arc and ranges](/quest/m3/ts-fmt-wrappers.md) - `Arc` formats as `T`, and ranges as std's `Debug` - [Fold a match a bool decided](/quest/m3/ts-fold-bool.md) - `if matches!` and derived `==` drop a later match's dead arms - [Rename one instance](/quest/m3/ffi-instance-rename.md) - `rename` by an instance's path, once a consumer's clash needs it - [Into targets through a chain of From implementations](/quest/m3/ffi-from-chains.md) - `sources` follows more than one level, once a consumer's parameter needs it diff --git a/quest/m3/ts-fmt-wrappers.md b/quest/m3/ts-fmt-wrappers.md deleted file mode 100644 index 8fdc5a61f..000000000 --- a/quest/m3/ts-fmt-wrappers.md +++ /dev/null @@ -1,16 +0,0 @@ -# [S] Debug and Display of Arc and ranges - -## Goal - -rust2-ts formats `Arc` as `T` formats with `Debug` and `Display`, and std's ranges with -`Debug`, byte for byte as std does, including format specs a range passes to its bounds. -Proven by differential tests against native Rust. - -## Plan - -Suggested by [#177](https://github.com/kixelated/rust2/pull/177) (`Arc`, refused for every -`T`) and [#179](https://github.com/kixelated/rust2/pull/179) (ranges) on 2026-10-27. rust2 -aims to support all of std. A drained `RangeInclusive` prints `exhausted` in its `Debug`, -which [the range fold](/quest/m3/ts-range-fold.md) makes observable. - -Public API: the translator's output. diff --git a/ts/fixtures/lang/expected/fmt.Clip.ts b/ts/fixtures/lang/expected/fmt.Clip.ts new file mode 100644 index 000000000..8e3125729 --- /dev/null +++ b/ts/fixtures/lang/expected/fmt.Clip.ts @@ -0,0 +1,19 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; + +/** `Debug` that pads its text, so a width and precision passed to it show, and marks `#`. */ +export interface Clip { + _0: string; +} + +export function fmt$Debug(self: Clip, f: rt.Formatter): rt.Result { + if (rt.fmtAlternate(f)) { + if (!rt.fmtWriteStr(f, "#").ok) { + return rt.Err(new rt.FmtError()); + } + } + return rt.fmtPad(f, self._0); +} + +//# sourceMappingURL=fmt.Clip.ts.map diff --git a/ts/fixtures/lang/expected/fmt.Shared.ts b/ts/fixtures/lang/expected/fmt.Shared.ts new file mode 100644 index 000000000..c797c59c1 --- /dev/null +++ b/ts/fixtures/lang/expected/fmt.Shared.ts @@ -0,0 +1,33 @@ +// Generated by rust2-ts. Do not edit. + +import * as rt from "./rt.ts"; +import * as Pair from "./fmt.Pair.ts"; + +export function fmt$Debug(self: Shared, f: rt.Formatter): rt.Result { + const _3: string = "Shared"; + const _4: string = "arc"; + const _5: rt.Fmt = (f: rt.Formatter) => Pair.fmt$Debug(self.arc.value, f); + const _7: string = "span"; + const _8: rt.Fmt = (f: rt.Formatter) => rt.fmtRange(self.span, f, rt.u16Debug); + const _10: string = "upto"; + const _11: rt.Fmt = (f: rt.Formatter) => rt.fmtRangeToInclusive(self.upto, f, rt.u8Debug); + return rt.debugStructFinish(rt.debugStructField(rt.debugStructField(rt.debugStructField(rt.fmtDebugStruct(f, _3), _4, _5), _7, _8), _10, _11)); +} + +export class Shared { + arc: rt.Arc; + span: rt.Range; + upto: { end: rt.u8; inclusive: true }; + + constructor(arc: rt.Arc, span: rt.Range, upto: { end: rt.u8; inclusive: true }) { + this.arc = arc; + this.span = span; + this.upto = upto; + } + + [Symbol.dispose](): void { + this.arc[Symbol.dispose](); + } +} + +//# sourceMappingURL=fmt.Shared.ts.map diff --git a/ts/fixtures/lang/expected/fmt.ts b/ts/fixtures/lang/expected/fmt.ts index 7411cf105..1bc962084 100644 --- a/ts/fixtures/lang/expected/fmt.ts +++ b/ts/fixtures/lang/expected/fmt.ts @@ -1,10 +1,11 @@ // Generated by rust2-ts. Do not edit. import * as rt from "./rt.ts"; -import { copy$Pair } from "./lib.ts"; +import { copy$Clip, copy$Pair } from "./lib.ts"; import { unwrapOr$Option_char, unwrapOr$Option_u8 } from "./core/option.ts"; import * as Bare from "./fmt.Bare.ts"; import * as Braced from "./fmt.Braced.ts"; +import * as Clip from "./fmt.Clip.ts"; import * as Fails from "./fmt.Fails.ts"; import * as Hex from "./fmt.Hex.ts"; import * as Kind from "./fmt.Kind.ts"; @@ -14,6 +15,7 @@ import * as Noted from "./fmt.Noted.ts"; import * as Padded from "./fmt.Padded.ts"; import * as Pair from "./fmt.Pair.ts"; import * as Seq from "./fmt.Seq.ts"; +import * as Shared from "./fmt.Shared.ts"; import * as Six from "./fmt.Six.ts"; import * as Tup from "./fmt.Tup.ts"; import * as Unit from "./fmt.Unit.ts"; @@ -596,4 +598,117 @@ export function panics(kind: rt.u8, rest: rt.ByteSlice, out: rt.ByteVec): void { } } +/** + * std's ranges' `Debug`, which passes its options to each bound, and an `Arc`'s `Debug` + * and `Display`, which pass them to what it holds. + */ +export function wrapped(data: rt.ByteSlice, out: rt.ByteVec): void { + const at: (a0: rt.usize) => rt.u8 = (i: rt.usize): rt.u8 => { + return unwrapOr$Option_u8(rt.byteSliceGet(data, i), 0); + }; + const _6: [rt.i32, rt.i32] = [rt.i32Sub(at(0) as rt.i32, 128), rt.i32Sub(at(1) as rt.i32, 100)]; + const a: rt.i32 = _6[0]; + const b: rt.i32 = _6[1]; + const w: rt.usize = rt.u8Rem(at(2), 10) as rt.usize; + const _33: rt.Range = new rt.Range(a, b); + const _35: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.i32Step); + const _37: { start: rt.i32 } = { start: a }; + const _39: { end: rt.i32 } = { end: b }; + const _41: { end: rt.i32; inclusive: true } = { end: b, inclusive: true }; + const args2: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_33, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(_35, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeFrom(_37, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeTo(_39, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_41, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeFull(undefined, f)]; + put(out, rt.fmtFormat([args2[0], " ", args2[1], " ", args2[2], " ", args2[3], " ", args2[4], " ", args2[5]])); + const _60: rt.Range = new rt.Range(a, b); + const _62: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.i32Step); + const _64: { start: rt.i32 } = { start: a }; + const _66: { end: rt.i32 } = { end: b }; + const _68: { end: rt.i32; inclusive: true } = { end: b, inclusive: true }; + const _70: rt.Range = new rt.Range(a, b); + const _72: rt.RangeInclusive = new rt.RangeInclusive(a, b, rt.i32Step); + const _74: { end: rt.i32; inclusive: true } = { end: b, inclusive: true }; + const _75: undefined = undefined; + const _77: rt.Range = new rt.Range(a, b); + const args4: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_60, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(_62, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeFrom(_64, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeTo(_66, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeToInclusive(_68, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRange(_70, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(_72, f, rt.i32Debug), rt.fmtCount(w), (f: rt.Formatter) => rt.fmtRangeToInclusive(_74, f, rt.i32Debug), (f: rt.Formatter) => rt.fmtRangeFull(_75, f), (f: rt.Formatter) => rt.fmtRange(_77, f, rt.i32Debug)]; + put(out, rt.fmtFormat([rt.fmtSpec({ width: 5 }, args4[0]), "|", rt.fmtSpec({ align: "<", width: 4 }, args4[1]), "|", rt.fmtSpec({ plus: true }, args4[2]), "|", rt.fmtSpec({ zero: true, width: 5 }, args4[3]), "|", rt.fmtSpec({ debugHex: "x" }, args4[4]), "|", rt.fmtSpec({ alternate: true, debugHex: "X" }, args4[5]), "|", rt.fmtSpec({ width: rt.fmtCountOf(args4[7]) }, args4[6]), "|", rt.fmtSpec({ align: "^", width: rt.fmtCountOf(args4[7]) }, args4[8]), "|", rt.fmtSpec({ align: ">", width: 3 }, args4[9]), "|", rt.fmtSpec({ alternate: true }, args4[10])])); + const _96: rt.usize = rt.usizeRem(at(3) as rt.usize, ["", "a", "héllo", "日本語", "tab\tnew\nline\r", "quote\"back\\slash'", "\u0000\u0001\u001f", "€Ÿ ­", "é", "‍ᅟ\u2028 ", "͸􏿽𽀀𿱀", "😀 🇦", "゙゚ン", "{}"].length); + if (!(_96 < 14)) { + rt.panic("index out of bounds: the len is " + 14 + " but the index is " + _96); + } + const lo: Clip.Clip = { _0: ["", "a", "héllo", "日本語", "tab\tnew\nline\r", "quote\"back\\slash'", "\u0000\u0001\u001f", "€Ÿ ­", "é", "‍ᅟ\u2028 ", "͸􏿽𽀀𿱀", "😀 🇦", "゙゚ン", "{}"][_96] }; + const _109: rt.usize = rt.usizeRem(at(4) as rt.usize, ["", "a", "héllo", "日本語", "tab\tnew\nline\r", "quote\"back\\slash'", "\u0000\u0001\u001f", "€Ÿ ­", "é", "‍ᅟ\u2028 ", "͸􏿽𽀀𿱀", "😀 🇦", "゙゚ン", "{}"].length); + if (!(_109 < 14)) { + rt.panic("index out of bounds: the len is " + 14 + " but the index is " + _109); + } + const hi: Clip.Clip = { _0: ["", "a", "héllo", "日本語", "tab\tnew\nline\r", "quote\"back\\slash'", "\u0000\u0001\u001f", "€Ÿ ­", "é", "‍ᅟ\u2028 ", "͸􏿽𽀀𿱀", "😀 🇦", "゙゚ン", "{}"][_109] }; + const _127: rt.Range = new rt.Range(lo, hi); + const _129: rt.RangeInclusive = new rt.RangeInclusive(copy$Clip(lo), copy$Clip(hi)); + const _131: { end: Clip.Clip } = { end: hi }; + const _133: { start: Clip.Clip } = { start: lo }; + const _135: { end: Clip.Clip; inclusive: true } = { end: lo, inclusive: true }; + const args6: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_127, f, (value: Clip.Clip, f: rt.Formatter) => Clip.fmt$Debug(value, f)), (f: rt.Formatter) => rt.fmtRangeInclusive(_129, f, (value: Clip.Clip, f: rt.Formatter) => Clip.fmt$Debug(value, f)), (f: rt.Formatter) => rt.fmtRangeTo(_131, f, (value: Clip.Clip, f: rt.Formatter) => Clip.fmt$Debug(value, f)), (f: rt.Formatter) => rt.fmtRangeFrom(_133, f, (value: Clip.Clip, f: rt.Formatter) => Clip.fmt$Debug(value, f)), rt.fmtCount(w), (f: rt.Formatter) => rt.fmtRangeToInclusive(_135, f, (value: Clip.Clip, f: rt.Formatter) => Clip.fmt$Debug(value, f))]; + put(out, rt.fmtFormat([args6[0], "|", rt.fmtSpec({ width: 8, precision: 2 }, args6[1]), "|", rt.fmtSpec({ alternate: true }, args6[2]), "|", rt.fmtSpec({ fill: "_", align: ">", width: rt.fmtCountOf(args6[4]), precision: 1 }, args6[3]), "|", rt.fmtSpec({ alternate: true, width: 4 }, args6[5])])); + const _148: [rt.u32, rt.u32] = [rt.u32Mul(at(5) as rt.u32, 257), at(6) as rt.u32]; + const x: rt.u32 = _148[0]; + const y: rt.u32 = _148[1]; + const _167: rt.Range = new rt.Range({ _0: x }, { _0: y }); + const _171: rt.RangeInclusive = new rt.RangeInclusive({ _0: x }, { _0: y }); + const _175: { end: Hex.Hex } = { end: { _0: y } }; + const args8: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(_167, f, (value: Hex.Hex, f: rt.Formatter) => Hex.fmt$Debug(value, f)), (f: rt.Formatter) => rt.fmtRangeInclusive(_171, f, (value: Hex.Hex, f: rt.Formatter) => Hex.fmt$Debug(value, f)), (f: rt.Formatter) => rt.fmtRangeTo(_175, f, (value: Hex.Hex, f: rt.Formatter) => Hex.fmt$Debug(value, f))]; + put(out, rt.fmtFormat([args8[0], "|", rt.fmtSpec({ align: ">", width: 9 }, args8[1]), "|", rt.fmtSpec({ alternate: true }, args8[2])])); + const part3 = new rt.Range({ _0: at(7), _1: -1 }, { _0: 1, _1: { hi: -0x80000000, lo: 0 } as rt.i64 }); + const args10: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(part3, f, (value: Pair.Pair, f: rt.Formatter) => Pair.fmt$Debug(value, f))]; + put(out, rt.fmtFormat([args10[0], "|", rt.fmtSpec({ alternate: true }, args10[0]), "|", rt.fmtSpec({ debugHex: "x" }, args10[0]), "|", rt.fmtSpec({ plus: true }, args10[0])])); + const drained: rt.RangeInclusive = new rt.RangeInclusive(rt.u8Rem(at(8), 4), rt.u8Rem(at(9), 4), rt.u8Step); + while (rt.iterToOption(drained.next()) !== undefined) { + } + const top: rt.RangeInclusive = new rt.RangeInclusive(rt.max(at(8), 250), 255, rt.u8Step); + while (rt.iterToOption(top.next()) !== undefined) { + } + const back: rt.RangeInclusive = new rt.RangeInclusive(0, rt.u8Rem(at(9), 3), rt.u8Step); + while (rt.iterToOption(back.nextBack()) !== undefined) { + } + const far: rt.RangeInclusive = new rt.RangeInclusive(at(8), at(9), rt.u8Step); + const _244: rt.usize = rt.u8Rem(at(10), 8) as rt.usize; + rt.iterNth(far, _244); + const _257: rt.RangeInclusive = new rt.RangeInclusive(0, 0, rt.i32Step); + const args12: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRangeInclusive(drained, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(top, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(back, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(far, f, rt.u8Debug), (f: rt.Formatter) => rt.fmtRangeInclusive(_257, f, rt.i32Debug)]; + put(out, rt.fmtFormat([args12[0], " ", args12[1], " ", args12[2], " ", args12[3], " ", args12[4]])); + const arc: rt.Arc = new rt.Arc({ _0: x }); + const args14: rt.Fmt[] = [(f: rt.Formatter) => Hex.fmt$Display(arc.value, f), (f: rt.Formatter) => Hex.fmt$Debug(arc.value, f)]; + put(out, rt.fmtFormat([args14[0], "|", rt.fmtSpec({ align: ">", width: 12 }, args14[0]), "|", rt.fmtSpec({ alternate: true }, args14[0]), "|", args14[1], "|", rt.fmtSpec({ align: ">", width: 6 }, args14[1]), "|", rt.fmtSpec({ alternate: true }, args14[1])])); + put(out, rt.fmtToString((f: rt.Formatter) => Hex.fmt$Display(arc.value, f))); + const nested_: rt.Arc> = new rt.Arc(new rt.Arc(a)); + const args16: rt.Fmt[] = [(f: rt.Formatter) => rt.i32Display(nested_.value.value, f), (f: rt.Formatter) => rt.i32Debug(nested_.value.value, f), rt.fmtCount(w)]; + put(out, rt.fmtFormat([args16[0], "|", rt.fmtSpec({ plus: true, zero: true, width: 5 }, args16[0]), "|", args16[1], "|", rt.fmtSpec({ debugHex: "x" }, args16[1]), "|", rt.fmtSpec({ alternate: true, debugHex: "X" }, args16[1]), "|", rt.fmtSpec({ align: "<", width: 6 }, args16[1]), "|", rt.fmtSpec({ align: "^", plus: true, width: rt.fmtCountOf(args16[2]) }, args16[0])])); + const _310: rt.usize = rt.usizeRem(at(3) as rt.usize, ["", "a", "héllo", "日本語", "tab\tnew\nline\r", "quote\"back\\slash'", "\u0000\u0001\u001f", "€Ÿ ­", "é", "‍ᅟ\u2028 ", "͸􏿽𽀀𿱀", "😀 🇦", "゙゚ン", "{}"].length); + if (!(_310 < 14)) { + rt.panic("index out of bounds: the len is " + 14 + " but the index is " + _310); + } + const rc: rt.Arc = new rt.Arc(["", "a", "héllo", "日本語", "tab\tnew\nline\r", "quote\"back\\slash'", "\u0000\u0001\u001f", "€Ÿ ­", "é", "‍ᅟ\u2028 ", "͸􏿽𽀀𿱀", "😀 🇦", "゙゚ン", "{}"][_310]); + const args18: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, rc.value), (f: rt.Formatter) => rt.fmtStr(rc.value, f)]; + put(out, rt.fmtFormat([args18[0], "|", rt.fmtSpec({ align: ">", width: 8, precision: 2 }, args18[0]), "|", args18[1]])); + const list: rt.Arc = new rt.Arc([{ _0: at(7), _1: 2 }, { _0: 3, _1: -4 }].map(copy$Pair)); + const args20: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtList(list.value, f, (value: Pair.Pair, f: rt.Formatter) => Pair.fmt$Debug(value, f))]; + put(out, rt.fmtFormat([args20[0], " ", rt.fmtSpec({ alternate: true }, args20[0])])); + const held: rt.Range> = new rt.Range(new rt.Arc(a), new rt.Arc(b)); + const _366: rt.Range> = new rt.Range(new rt.Arc(copy$Clip(lo)), new rt.Arc(copy$Clip(hi))); + const args22: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtRange(held, f, (value: rt.Arc, f: rt.Formatter) => rt.i32Debug(value.value, f)), (f: rt.Formatter) => rt.fmtRange(_366, f, (value: rt.Arc, f: rt.Formatter) => Clip.fmt$Debug(value.value, f))]; + put(out, rt.fmtFormat([args22[0], " ", rt.fmtSpec({ plus: true, zero: true, width: 4 }, args22[0]), " ", args22[1]])); + const shared: Shared.Shared = new Shared.Shared(new rt.Arc({ _0: at(7), _1: 5 }), new rt.Range(at(8) as rt.u16, 300), { end: at(9), inclusive: true }); + const args24: rt.Fmt[] = [(f: rt.Formatter) => Shared.fmt$Debug(shared, f)]; + put(out, rt.fmtFormat([args24[0], " ", rt.fmtSpec({ alternate: true }, args24[0])])); + const _405: rt.usize = rt.usizeRem(at(3) as rt.usize, ["", "a", "héllo", "日本語", "tab\tnew\nline\r", "quote\"back\\slash'", "\u0000\u0001\u001f", "€Ÿ ­", "é", "‍ᅟ\u2028 ", "͸􏿽𽀀𿱀", "😀 🇦", "゙゚ン", "{}"].length); + if (!(_405 < 14)) { + rt.panic("index out of bounds: the len is " + 14 + " but the index is " + _405); + } + const t: rt.Arc = new rt.Arc(["", "a", "héllo", "日本語", "tab\tnew\nline\r", "quote\"back\\slash'", "\u0000\u0001\u001f", "€Ÿ ­", "é", "‍ᅟ\u2028 ", "͸􏿽𽀀𿱀", "😀 🇦", "゙゚ン", "{}"][_405]); + const args26: rt.Fmt[] = [(f: rt.Formatter) => rt.fmtPad(f, t.value), (f: rt.Formatter) => rt.fmtStr(t.value, f)]; + put(out, rt.fmtFormat([args26[0], " ", args26[1], " ", rt.fmtSpec({ align: ">", width: 9, precision: 2 }, args26[0])])); + t[Symbol.dispose](); + shared[Symbol.dispose](); + list[Symbol.dispose](); + rc[Symbol.dispose](); + nested_[Symbol.dispose](); + arc[Symbol.dispose](); +} + //# sourceMappingURL=fmt.ts.map diff --git a/ts/fixtures/lang/expected/harness.ts b/ts/fixtures/lang/expected/harness.ts index e05388b78..d17b06d48 100644 --- a/ts/fixtures/lang/expected/harness.ts +++ b/ts/fixtures/lang/expected/harness.ts @@ -18,7 +18,7 @@ import { durations } from "./durations.ts"; import { dyns, shared, anys, fns } from "./dyns.ts"; import { edits, bytes } from "./edits.ts"; import { floats } from "./floats.ts"; -import { ints, strings, derived, written, counts, rounding, panics } from "./fmt.ts"; +import { ints, strings, derived, written, counts, rounding, panics, wrapped } from "./fmt.ts"; import { methods } from "./generics.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 } from "./ints.ts"; @@ -42,101 +42,103 @@ import { wrappers } from "./wrappers.ts"; * case added at the end moves no other. */ export function cases(): [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void][] { - return copy$str_forabfnu8au8bmutstdvecVecu8s([["ints::u8_op", u8Op] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::u16_op", u16Op] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::u32_op", u32Op] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::u64_op", u64Op] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::u128_op", u128Op] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::usize_op", usizeOp] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::i8_op", i8Op] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::i16_op", i16Op] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::i32_op", i32Op] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::i64_op", i64Op] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::i128_op", i128Op] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::isize_op", isizeOp] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::neg", neg] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::cast", cast] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::convert", (_276: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void => { + return copy$str_forabfnu8au8bmutstdvecVecu8s([["ints::u8_op", u8Op] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::u16_op", u16Op] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::u32_op", u32Op] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::u64_op", u64Op] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::u128_op", u128Op] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::usize_op", usizeOp] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::i8_op", i8Op] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::i16_op", i16Op] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::i32_op", i32Op] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::i64_op", i64Op] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::i128_op", i128Op] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::isize_op", isizeOp] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::neg", neg] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::cast", cast] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["ints::convert", (_279: rt.u8, data: rt.ByteSlice, out: rt.ByteVec): void => { convert(data, out); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["shapes::copies", (_277: rt.u8, data2: rt.ByteSlice, out2: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["shapes::copies", (_280: rt.u8, data2: rt.ByteSlice, out2: rt.ByteVec): void => { shapes_copies(data2, out2); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["shapes::loops", (_278: rt.u8, data3: rt.ByteSlice, out3: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["shapes::loops", (_281: rt.u8, data3: rt.ByteSlice, out3: rt.ByteVec): void => { loops(data3, out3); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["shapes::patterns", (_279: rt.u8, data4: rt.ByteSlice, out4: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["shapes::patterns", (_282: rt.u8, data4: rt.ByteSlice, out4: rt.ByteVec): void => { patterns(data4, out4); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["shapes::closures", (_280: rt.u8, data5: rt.ByteSlice, out5: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["shapes::closures", (_283: rt.u8, data5: rt.ByteSlice, out5: rt.ByteVec): void => { closures(data5, out5); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["shapes::discriminants", (_281: rt.u8, data6: rt.ByteSlice, out6: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["shapes::discriminants", (_284: rt.u8, data6: rt.ByteSlice, out6: rt.ByteVec): void => { discriminants(data6, out6); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["shapes::library", (_282: rt.u8, data7: rt.ByteSlice, out7: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["shapes::library", (_285: rt.u8, data7: rt.ByteSlice, out7: rt.ByteVec): void => { library(data7, out7); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["fmt::ints", ints] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["fmt::strings", (_283: rt.u8, data8: rt.ByteSlice, out8: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["fmt::ints", ints] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["fmt::strings", (_286: rt.u8, data8: rt.ByteSlice, out8: rt.ByteVec): void => { strings(data8, out8); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["fmt::derived", (_284: rt.u8, data9: rt.ByteSlice, out9: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["fmt::derived", (_287: rt.u8, data9: rt.ByteSlice, out9: rt.ByteVec): void => { derived(data9, out9); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["fmt::written", (_285: rt.u8, data10: rt.ByteSlice, out10: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["fmt::written", (_288: rt.u8, data10: rt.ByteSlice, out10: rt.ByteVec): void => { written(data10, out10); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["fmt::panics", panics] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["generics::methods", (_286: rt.u8, data11: rt.ByteSlice, out11: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["fmt::panics", panics] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["generics::methods", (_289: rt.u8, data11: rt.ByteSlice, out11: rt.ByteVec): void => { methods(data11, out11); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["iters::adaptors", adaptors] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["iters::consumers", consumers] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["iters::ranges", (_287: rt.u8, data12: rt.ByteSlice, out12: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["iters::adaptors", adaptors] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["iters::consumers", consumers] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["iters::ranges", (_290: rt.u8, data12: rt.ByteSlice, out12: rt.ByteVec): void => { ranges(data12, out12); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["iters::options", (_288: rt.u8, data13: rt.ByteSlice, out13: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["iters::options", (_291: rt.u8, data13: rt.ByteSlice, out13: rt.ByteVec): void => { options(data13, out13); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["iters::own", (_289: rt.u8, data14: rt.ByteSlice, out14: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["iters::own", (_292: rt.u8, data14: rt.ByteSlice, out14: rt.ByteVec): void => { own(data14, out14); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["iters::values", (_290: rt.u8, data15: rt.ByteSlice, out15: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["iters::values", (_293: rt.u8, data15: rt.ByteSlice, out15: rt.ByteVec): void => { values(data15, out15); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["shapes::order", (_291: rt.u8, data16: rt.ByteSlice, out16: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["shapes::order", (_294: rt.u8, data16: rt.ByteSlice, out16: rt.ByteVec): void => { order(data16, out16); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["collections::hash_maps", hashMaps] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["collections::sets", sets] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["collections::btree_maps", btreeMaps] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["collections::deques", (_292: rt.u8, data17: rt.ByteSlice, out17: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["collections::hash_maps", hashMaps] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["collections::sets", sets] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["collections::btree_maps", btreeMaps] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["collections::deques", (_295: rt.u8, data17: rt.ByteSlice, out17: rt.ByteVec): void => { deques(data17, out17); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["shapes::flows", (_293: rt.u8, data18: rt.ByteSlice, out18: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["shapes::flows", (_296: rt.u8, data18: rt.ByteSlice, out18: rt.ByteVec): void => { flows(data18, out18); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["keys::keys", keys] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["chars::chars", chars] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["strs::strs", strs] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["collections::vecs", (_294: rt.u8, data19: rt.ByteSlice, out19: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["keys::keys", keys] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["chars::chars", chars] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["strs::strs", strs] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["collections::vecs", (_297: rt.u8, data19: rt.ByteSlice, out19: rt.ByteVec): void => { vecs(data19, out19); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["strs::slices", slices] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["collections::stores", (_295: rt.u8, data20: rt.ByteSlice, out20: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["strs::slices", slices] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["collections::stores", (_298: rt.u8, data20: rt.ByteSlice, out20: rt.ByteVec): void => { stores(data20, out20); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["chunks::chunks", chunks] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["cows::cows", cows] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["durations::durations", durations] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["combinators::combinators", combinators] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["splits::splits", splits] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["nested::nested", nested] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["refs::refs", (_296: rt.u8, data21: rt.ByteSlice, out21: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["chunks::chunks", chunks] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["cows::cows", cows] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["durations::durations", durations] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["combinators::combinators", combinators] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["splits::splits", splits] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["nested::nested", nested] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["refs::refs", (_299: rt.u8, data21: rt.ByteSlice, out21: rt.ByteVec): void => { refs(data21, out21); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["fmt::counts", (_297: rt.u8, data22: rt.ByteSlice, out22: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["fmt::counts", (_2100: rt.u8, data22: rt.ByteSlice, out22: rt.ByteVec): void => { counts(data22, out22); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["fmt::rounding", (_298: rt.u8, _310: rt.ByteSlice, out23: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["fmt::rounding", (_2101: rt.u8, _310: rt.ByteSlice, out23: rt.ByteVec): void => { rounding(out23); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["iters::skips", skips] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["wrappers::wrappers", wrappers] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["edits::edits", edits] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["utf8::decodes", decodes] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["floats::floats", floats] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["atomics::atomics", atomics] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["keys::overrides", overrides] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["dyns::dyns", (_299: rt.u8, data23: rt.ByteSlice, out24: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["iters::skips", skips] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["wrappers::wrappers", wrappers] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["edits::edits", edits] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["utf8::decodes", decodes] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["floats::floats", floats] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["atomics::atomics", atomics] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["keys::overrides", overrides] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["dyns::dyns", (_2102: rt.u8, data23: rt.ByteSlice, out24: rt.ByteVec): void => { dyns(data23, out24); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["cells::cells", cells] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["dyns::shared", (_2100: rt.u8, data24: rt.ByteSlice, out25: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["cells::cells", cells] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["dyns::shared", (_2103: rt.u8, data24: rt.ByteSlice, out25: rt.ByteVec): void => { shared(data24, out25); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["iters::ranked", ranked] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["captures::captures", captures] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["locks::locks", (_2101: rt.u8, data25: rt.ByteSlice, out26: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["iters::ranked", ranked] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["captures::captures", captures] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["locks::locks", (_2104: rt.u8, data25: rt.ByteSlice, out26: rt.ByteVec): void => { locks(data25, out26); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["locks::relock", (_2102: rt.u8, data26: rt.ByteSlice, out27: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["locks::relock", (_2105: rt.u8, data26: rt.ByteSlice, out27: rt.ByteVec): void => { relock(data26, out27); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["locals::locals", (_2103: rt.u8, data27: rt.ByteSlice, out28: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["locals::locals", (_2106: rt.u8, data27: rt.ByteSlice, out28: rt.ByteVec): void => { locals(data27, out28); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["statics::statics", (_2104: rt.u8, data28: rt.ByteSlice, out29: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["statics::statics", (_2107: rt.u8, data28: rt.ByteSlice, out29: rt.ByteVec): void => { statics(data28, out29); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["locks::rwlocks", (_2105: rt.u8, data29: rt.ByteSlice, out30: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["locks::rwlocks", (_2108: rt.u8, data29: rt.ByteSlice, out30: rt.ByteVec): void => { rwlocks(data29, out30); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["borrows::borrows", (_2106: rt.u8, data30: rt.ByteSlice, out31: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["borrows::borrows", (_2109: rt.u8, data30: rt.ByteSlice, out31: rt.ByteVec): void => { borrows(data30, out31); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["defaults::defaults", (_2107: rt.u8, data31: rt.ByteSlice, out32: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["defaults::defaults", (_2110: rt.u8, data31: rt.ByteSlice, out32: rt.ByteVec): void => { defaults(data31, out32); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["counts::arcs", (_2108: rt.u8, data32: rt.ByteSlice, out33: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["counts::arcs", (_2111: rt.u8, data32: rt.ByteSlice, out33: rt.ByteVec): void => { arcs(data32, out33); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["counts::rcs", (_2109: rt.u8, data33: rt.ByteSlice, out34: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["counts::rcs", (_2112: rt.u8, data33: rt.ByteSlice, out34: rt.ByteVec): void => { rcs(data33, out34); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["counts::cyclic_arcs", (_2110: rt.u8, data34: rt.ByteSlice, out35: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["counts::cyclic_arcs", (_2113: rt.u8, data34: rt.ByteSlice, out35: rt.ByteVec): void => { cyclicArcs(data34, out35); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["counts::cyclic_rcs", (_2111: rt.u8, data35: rt.ByteSlice, out36: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["counts::cyclic_rcs", (_2114: rt.u8, data35: rt.ByteSlice, out36: rt.ByteVec): void => { cyclicRcs(data35, out36); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["dyns::anys", (_2112: rt.u8, data36: rt.ByteSlice, out37: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["dyns::anys", (_2115: rt.u8, data36: rt.ByteSlice, out37: rt.ByteVec): void => { anys(data36, out37); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["dyns::fns", (_2113: rt.u8, data37: rt.ByteSlice, out38: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["dyns::fns", (_2116: rt.u8, data37: rt.ByteSlice, out38: rt.ByteVec): void => { fns(data37, out38); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["pointers::copies", (_2114: rt.u8, data38: rt.ByteSlice, out39: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["pointers::copies", (_2117: rt.u8, data38: rt.ByteSlice, out39: rt.ByteVec): void => { copies(data38, out39); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["pointers::lists", (_2115: rt.u8, data39: rt.ByteSlice, out40: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["pointers::lists", (_2118: rt.u8, data39: rt.ByteSlice, out40: rt.ByteVec): void => { lists(data39, out40); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["pointers::nested", (_2116: rt.u8, data40: rt.ByteSlice, out41: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["pointers::nested", (_2119: rt.u8, data40: rt.ByteSlice, out41: rt.ByteVec): void => { pointers_nested(data40, out41); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["pointers::places", (_2117: rt.u8, data41: rt.ByteSlice, out42: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["pointers::places", (_2120: rt.u8, data41: rt.ByteSlice, out42: rt.ByteVec): void => { places(data41, out42); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["pointers::sentinels", (_2118: rt.u8, data42: rt.ByteSlice, out43: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["pointers::sentinels", (_2121: rt.u8, data42: rt.ByteSlice, out43: rt.ByteVec): void => { sentinels(data42, out43); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["pointers::shared", (_2119: rt.u8, data43: rt.ByteSlice, out44: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["pointers::shared", (_2122: rt.u8, data43: rt.ByteSlice, out44: rt.ByteVec): void => { pointers_shared(data43, out44); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["pointers::unchecked", (_2120: rt.u8, data44: rt.ByteSlice, out45: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["pointers::unchecked", (_2123: rt.u8, data44: rt.ByteSlice, out45: rt.ByteVec): void => { unchecked(data44, out45); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["edits::bytes", bytes] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["arrays::from_fns", (_2121: rt.u8, data45: rt.ByteSlice, out46: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["edits::bytes", bytes] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["arrays::from_fns", (_2124: rt.u8, data45: rt.ByteSlice, out46: rt.ByteVec): void => { fromFns(data45, out46); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["collections::optionals", optionals] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["objects::objects", (_2122: rt.u8, data46: rt.ByteSlice, out47: rt.ByteVec): void => { + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["collections::optionals", optionals] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["objects::objects", (_2125: rt.u8, data46: rt.ByteSlice, out47: rt.ByteVec): void => { objects(data46, out47); - }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["holds::holds", holds] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void]]).map(copy$str_forabfnu8au8bmutstdvecVecu8); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["holds::holds", holds] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void], ["fmt::wrapped", (_2126: rt.u8, data47: rt.ByteSlice, out48: rt.ByteVec): void => { + wrapped(data47, out48); + }] as [string, (a0: rt.u8, a1: rt.ByteSlice, a2: rt.ByteVec) => void]]).map(copy$str_forabfnu8au8bmutstdvecVecu8); } /** Run one case. */ diff --git a/ts/fixtures/lang/expected/lib.ts b/ts/fixtures/lang/expected/lib.ts index 426a07176..80a0043bf 100644 --- a/ts/fixtures/lang/expected/lib.ts +++ b/ts/fixtures/lang/expected/lib.ts @@ -4,6 +4,7 @@ import * as rt from "./rt.ts"; import type * as Tally from "./collections.Tally.ts"; import type * as Any from "./core/any.Any.ts"; import type * as Window from "./durations.Window.ts"; +import type * as Clip from "./fmt.Clip.ts"; import type * as Pair from "./fmt.Pair.ts"; import type * as Either from "./generics.Either.ts"; import * as Wrap from "./generics.Wrap.ts"; @@ -34,6 +35,10 @@ export function copy$Bumped(v: Bumped.Bumped): Bumped.Bumped { return { _0: v._0 }; } +export function copy$Clip(v: Clip.Clip): Clip.Clip { + return { _0: v._0 }; +} + export function copy$ControlFlow_Arc_u8_u8s(v: rt.Result>): rt.Result> { return v.ok ? rt.Ok(copy$u8s(v.value)) : rt.Err(v.error); } diff --git a/ts/fixtures/lang/src/fmt.rs b/ts/fixtures/lang/src/fmt.rs index d75da7a5a..e0cd32cd4 100644 --- a/ts/fixtures/lang/src/fmt.rs +++ b/ts/fixtures/lang/src/fmt.rs @@ -4,6 +4,9 @@ #![allow(dead_code, reason = "fields only `Debug` reads")] use std::fmt; +use std::ops::{Range, RangeToInclusive}; +use std::rc::Rc; +use std::sync::Arc; use crate::generics::Wrap; use crate::shapes::{Point, Shape}; @@ -559,6 +562,107 @@ pub fn panics(kind: u8, rest: &[u8], out: &mut Vec) { } } +/// `Debug` that pads its text, so a width and precision passed to it show, and marks `#`. +#[derive(Clone, Copy)] +pub struct Clip(&'static str); + +impl fmt::Debug for Clip { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if f.alternate() { + f.write_str("#")?; + } + f.pad(self.0) + } +} + +#[derive(Debug)] +pub struct Shared { + arc: Arc, + span: Range, + upto: RangeToInclusive, +} + +/// std's ranges' `Debug`, which passes its options to each bound, and an `Arc`'s `Debug` +/// and `Display`, which pass them to what it holds. +pub fn wrapped(data: &[u8], out: &mut Vec) { + let at = |i: usize| data.get(i).copied().unwrap_or(0); + let (a, b) = (i32::from(at(0)) - 128, i32::from(at(1)) - 100); + let w = usize::from(at(2) % 10); + put( + out, + &format!("{:?} {:?} {:?} {:?} {:?} {:?}", a..b, a..=b, a.., ..b, ..=b, ..), + ); + put( + out, + &format!( + "{:5?}|{:<4?}|{:+?}|{:05?}|{:x?}|{:#X?}|{:w$?}|{:^w$?}|{:>3?}|{:#?}", + a..b, + a..=b, + a.., + ..b, + ..=b, + a..b, + a..=b, + ..=b, + .., + a..b + ), + ); + let lo = Clip(STRINGS[usize::from(at(3)) % STRINGS.len()]); + let hi = Clip(STRINGS[usize::from(at(4)) % STRINGS.len()]); + put( + out, + &format!( + "{:?}|{:8.2?}|{:#?}|{:_>w$.1?}|{:#4?}", + lo..hi, + lo..=hi, + ..hi, + lo.., + ..=lo + ), + ); + let (x, y) = (u32::from(at(5)) * 0x101, u32::from(at(6))); + put( + out, + &format!("{:?}|{:>9?}|{:#?}", Hex(x)..Hex(y), Hex(x)..=Hex(y), ..Hex(y)), + ); + let pairs = Pair(at(7), -1)..Pair(1, i64::MIN); + put(out, &format!("{pairs:?}|{pairs:#?}|{pairs:x?}|{pairs:+?}")); + // Iteration leaves an inclusive range in the state its `Debug` prints. + let mut drained = (at(8) % 4)..=(at(9) % 4); + while drained.next().is_some() {} + let mut top = at(8).max(250)..=255; + while top.next().is_some() {} + let mut back = 0..=(at(9) % 3); + while back.next_back().is_some() {} + let mut far = at(8)..=at(9); + far.nth(usize::from(at(10) % 8)); + put(out, &format!("{drained:?} {top:?} {back:?} {far:?} {:?}", 0..=0)); + + let arc = Arc::new(Hex(x)); + put(out, &format!("{arc}|{arc:>12}|{arc:#}|{arc:?}|{arc:>6?}|{arc:#?}")); + put(out, &arc.to_string()); + let nested = Arc::new(Arc::new(a)); + put( + out, + &format!("{nested}|{nested:+05}|{nested:?}|{nested:x?}|{nested:#X?}|{nested:<6?}|{nested:^+w$}"), + ); + let rc = Rc::new(STRINGS[usize::from(at(3)) % STRINGS.len()].to_string()); + put(out, &format!("{rc}|{rc:>8.2}|{rc:?}")); + let list = Arc::new([Pair(at(7), 2), Pair(3, -4)].to_vec()); + put(out, &format!("{list:?} {list:#?}")); + let held = Arc::new(a)..Arc::new(b); + put(out, &format!("{held:?} {held:+04?} {:?}", Arc::new(lo)..Arc::new(hi))); + let shared = Shared { + arc: Arc::new(Pair(at(7), 5)), + span: u16::from(at(8))..300, + upto: ..=at(9), + }; + put(out, &format!("{shared:?} {shared:#?}")); + let t: Arc = Arc::from(STRINGS[usize::from(at(3)) % STRINGS.len()]); + put(out, &format!("{t} {t:?} {t:>9.2}")); +} + /// An error only a TypeScript caller prints, as moq's callers print its errors: nothing /// translated formats it, so its `Display` and `Debug` come along as `printable`. #[derive(Debug)] diff --git a/ts/fixtures/lang/src/harness.rs b/ts/fixtures/lang/src/harness.rs index 354738fa1..005213a9e 100644 --- a/ts/fixtures/lang/src/harness.rs +++ b/ts/fixtures/lang/src/harness.rs @@ -114,6 +114,7 @@ fn cases() -> Vec<(&'static str, Case)> { ("collections::optionals", collections::optionals), ("objects::objects", |_, data, out| objects::objects(data, out)), ("holds::holds", holds::holds), + ("fmt::wrapped", |_, data, out| fmt::wrapped(data, out)), ] } diff --git a/ts/runtime/rt.ts b/ts/runtime/rt.ts index 6f4c2b9b2..610888975 100644 --- a/ts/runtime/rt.ts +++ b/ts/runtime/rt.ts @@ -7,6 +7,7 @@ import type { Ordering } from "./rt/collections.ts"; import { type char, type TryFromIntError, type u32, type usize, u8Debug, usizeDebug, usizeDisplay } from "./rt/int.ts"; +import type { Range, RangeInclusive } from "./rt/iter.ts"; import { dropAll, type Pending } from "./rt/task.ts"; import { AtIndex } from "./rt/collections.ts"; @@ -1340,6 +1341,47 @@ export function fmtList(items: Iterable, f: Formatter, debug: Debug): F return debugListFinish(debugListEntries(fmtDebugList(f), items, debug)); } +/** `Debug` of a range: each bound present, written with the formatter's options, around `dots`, which none pads. */ +function fmtBounds(f: Formatter, start: Fmt | undefined, dots: string, end: Fmt | undefined): FmtResult { + if (start !== undefined) { + const r = start(f); + if (!r.ok) return r; + } + const r = f.out.writeStr(dots); + return r.ok && end !== undefined ? end(f) : r; +} + +/** `Debug` of `start..end`. */ +export function fmtRange(r: Range, f: Formatter, debug: Debug): FmtResult { + return fmtBounds(f, (f) => debug(r.start, f), "..", (f) => debug(r.end, f)); +} + +/** `Debug` of `start..=end`, which notes once iteration has exhausted it. */ +export function fmtRangeInclusive(r: RangeInclusive, f: Formatter, debug: Debug): FmtResult { + const result = fmtBounds(f, (f) => debug(r.lo, f), "..=", (f) => debug(r.hi, f)); + return result.ok && r.exhausted ? f.out.writeStr(" (exhausted)") : result; +} + +/** `Debug` of `start..`. */ +export function fmtRangeFrom(r: { start: T }, f: Formatter, debug: Debug): FmtResult { + return fmtBounds(f, (f) => debug(r.start, f), "..", undefined); +} + +/** `Debug` of `..end`. */ +export function fmtRangeTo(r: { end: T }, f: Formatter, debug: Debug): FmtResult { + return fmtBounds(f, undefined, "..", (f) => debug(r.end, f)); +} + +/** `Debug` of `..=end`. */ +export function fmtRangeToInclusive(r: { end: T }, f: Formatter, debug: Debug): FmtResult { + return fmtBounds(f, undefined, "..=", (f) => debug(r.end, f)); +} + +/** `Debug` of `..`. */ +export function fmtRangeFull(_: undefined, f: Formatter): FmtResult { + return f.out.writeStr(".."); +} + /** `Debug` of a tuple, given each element's. */ export function fmtTuple(fields: readonly Fmt[], f: Formatter): FmtResult { const builder = fmtDebugTuple(f, ""); diff --git a/ts/src/lower/consts.rs b/ts/src/lower/consts.rs index 7bbfa748a..6c58d2a3d 100644 --- a/ts/src/lower/consts.rs +++ b/ts/src/lower/consts.rs @@ -143,6 +143,7 @@ impl<'b, 'a, 'tcx> Body<'b, 'a, 'tcx> { super::library::range_to(values.pop().unwrap(), std == Std::RangeToInclusive) } (Std::RangeFrom, _) => Expr::Object(vec![(Key::Name("start".into()), values.pop().unwrap())]), + (Std::RangeFull, _) => Expr::undefined(), _ => self.err(span, format!("a constant of type `{ty}`")), }; } diff --git a/ts/src/lower/fmt.rs b/ts/src/lower/fmt.rs index fe50951fa..a6db2973c 100644 --- a/ts/src/lower/fmt.rs +++ b/ts/src/lower/fmt.rs @@ -270,6 +270,25 @@ pub fn std_impl<'tcx>( (Std::String | Std::Cow, Trait::Debug) if library::string(tcx, ty) => rt("str", vec![value, f]), // A `NonZero` writes its integer, by each trait. (Std::Box | Std::NonZero, _) => b.fmt_call(tr, args.type_at(0), value, f, span), + (Std::Arc, Trait::Display | Trait::Debug) => { + b.fmt_call(tr, args.type_at(0), value.member("value"), f, span) + } + // Each bound is written with the range's options. + ( + std @ (Std::Range | Std::RangeInclusive | Std::RangeFrom | Std::RangeTo | Std::RangeToInclusive), + Trait::Debug, + ) => { + let bound = b.fmt_fn(tr, args.type_at(0), span); + let of = match std { + Std::Range => "range", + Std::RangeInclusive => "rangeInclusive", + Std::RangeFrom => "rangeFrom", + Std::RangeTo => "rangeTo", + _ => "rangeToInclusive", + }; + rt(of, vec![value, f, bound]) + } + (Std::RangeFull, Trait::Debug) => rt("rangeFull", vec![value, f]), (Std::Vec, Trait::Debug) => { let item = b.fmt_fn(tr, args.type_at(0), span); rt("list", vec![library::elements(value, ty), f, item])