Files
v/doc/recursive_sum_printing.md
da62dd4bd7 v3: represent sum types as tagged unions (#29578)
* v3: represent sum types as tagged unions

* v3: fix sum projection lifetimes and parser storage

* sokol: fix sokol.audio on Windows TCC and fix simple_bytebeat example (fixes #30891)

- Fix TCC objbase.h bug where COINIT_MULTITHREADED is defined as 0x3 instead of 0x0, causing CoInitializeEx to fail with E_INVALIDARG and CoCreateInstance for IMMDeviceEnumerator to fail with CO_E_NOTINITIALIZED.
- Fix TCC missing 1-byte struct packing for WAVEFORMATEX / WAVEFORMATEXTENSIBLE, which caused IAudioClient_Initialize to fail with E_INVALIDARG.
- Fix simple_bytebeat.v user_data callback signature and frame count handling.
- Add sokol.audio setup/shutdown test in vlib/sokol/audio/audio_test.c.v.

* cmd/tools, ci: fix four failing master jobs

- cmd/tools/vup.v: build the self-rebuild argument list by appending
  instead of using an array spread. The release compiler that the
  v-up jobs use fails on the spread with "unexpected token `...`".
- cmd/tools/vls_test.v: apply v fmt to the two json2.encode calls.
  This clears the fmt check failure in the clang-macos job.
- vlib/v/gen/arm64/native_allocation_test.v: use tabs instead of four
  spaces for indentation. The change is whitespace-only.
- .github/workflows/v_apps_and_modules_compile_ci.yml: clone the docs
  generator into docs_generator. The repository tracks a docs
  directory, so cloning into docs failed on every run.

Co-Authored-By: WOZCODE <contact@withwoz.com>

* Add files via upload

* time: update bundled zoneinfo.zip to tzdata 2026e

The bundled zoneinfo.zip was built from tzdata 2025b. Windows has no
system zoneinfo, so time.load_location uses this file by default there;
so does any program that imports time.tzdata. Two changes since 2025b
make it wrong:

- tz 2026c: Morocco moved to permanent +00 on 2026-09-20, so
  Africa/Casablanca and Africa/El_Aaiun are already one hour off.
- tz 2026b-2026e: British Columbia, Alberta, the Northwest Territories
  and Manitoba keep their daylight offset after 2026-11-01, so
  America/Vancouver, Edmonton, Inuvik and Winnipeg are one hour off
  from that date.

The file is rebuilt with the tz make line that reproduces the 2025b
file byte for byte (make PACKRATDATA=backzone posix_only), with only
the release changed to 2026e; 29 of the 599 entries change.

Tests: test_bundled_zoneinfo_has_future_posix_rules now uses
America/Los_Angeles, because America/Vancouver no longer observes
PST/PDT in 2030. test_load_location_posix_fixed_future_rule expects
Morocco's new fixed +00. A new test checks the four Canadian zones in
December 2026.

* tools: keep the V3 module cache shared across `v test` sessions

`v test` points VTMP at a new `tsession_<id>` folder, and the V3 module
cache defaults to VTMP. Each session therefore started with an empty
module cache, compiled every cached module (builtin, os, time, ...) with
the C compiler again, and deleted them when the session ended. For a
test of a 69-file program this added about 17s to every run.

setup_new_vtmp_folder now sets V3CACHE to the shared VTMP before it
switches VTMP to the session folder, unless V3CACHE is already set or
V3_TEST_ISOLATE_CACHE=1 requests an isolated cache (V3CACHE would
override that request). Temporary files of the tests still go to the
session folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* examples: fix cached Collatz chains and guard integer bounds

* sokol: keep bytebeat frame state on the audio callback thread

* testing: cover and document shared V3 cache sessions

* ci: run the current updater with its matching standard library

* cgen: preserve pointer-sum ownership through loops and field replacement

* checker: reject pointer-sum loans escaping through aggregate stores

* sumtypes: preserve projection moves, mixed ownership, and library storage contracts

* ownership: preserve mixed-result loans through sum wrappers and storage

* sumtypes: preserve Result and Option ownership and aligned array references

* compiler: preserve fallback loans and fixed-array pointer sum slots

* compiler: correct type values and ownership flow clones

* compiler: isolate mutable fallback loop bindings

* compiler: preserve wrapped exits and fresh array ownership

* tests: preserve invalid native Type tag checks

* compiler: preserve mut slot contracts and native sum projections

* compiler: repair optional bridges, sum replacement, and native type identity

* compiler: preserve generic optional views and mutable sum storage

* types: preserve original references in lane lifetime fixtures

* fastc: preserve typed references for computed arguments

* fastc: preserve existing sum values in identity casts

* fastc: preserve original storage when reassigning smartcast sum pointers

* compiler: preserve owned sum cleanup and borrowed return lifetimes

* cgen: keep vectored output headers out of headerless compiler C

---------

Co-authored-by: Alexander Medvednikov <alexander@medvednikov.com>
Co-authored-by: Keito Tobichi <keito940@live.jp>
Co-authored-by: Richard Wheeler <18647491+PythonWillRule@users.noreply.github.com>
Co-authored-by: WOZCODE <contact@withwoz.com>
Co-authored-by: Karan Gupta <uft289@gmail.com>
Co-authored-by: CyberNative AI LLC <hello@cybernative.ai>
Co-authored-by: Jakub Jabłoński <jj@simplid.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 21:44:13 +03:00

730 B

Printing recursive sum types

Automatic printing follows distinct objects in recursive sum-type trees. Repeated payload types alone do not count as circular references. Nested directories in a tree, for example, retain their fields even when several levels use the same directory type.

When a payload points back to an object already being printed, the cycle is shown as <circular>. Shared objects reached through separate branches are printed in each branch.

Sum payloads use inline storage. Recursive trees need a reference or a dynamic collection to break the value layout cycle, for example type Tree = &Directory | File when Directory contains Tree fields. Reference variants also allow deliberate object cycles.