Skip to content

Recursive-by-value nodes and string-initialised numeric slices; and why the keyword field-name fix is blocked #2711

Description

@gHashTag

Two corpus defects that deliberate failing tests exposed, both fixed here, and one emitter fix that is entangled with an open decision and is therefore not.

Recursive by value — 9 fields in 6 files

A node type that contains itself by value has infinite size and cannot be named:

pub const Tree(T) = struct {
    left : "Tree(T)",
    right : "Tree(T)",
};

?T does not help — an optional of a value is still the value's size plus a tag — so ?ListNode and [8]?OctNode are the same defect wearing a question mark. All nine become ?*T, one word and terminating.

Found by following the chain rather than grepping one file: A holding B holding A is the same defect and a single-file scan misses it. Six declarations: Tree(T), List(T), ListNode, KDNode, OctNode, QuadNode.

Measured by running: tri/trees/tree.t27 went from 1 test passing, 1 failing on the infinite-size claim to 2 passing. octree 4 passing, quadtree and kd_tree likewise nameable.

A numeric slice initialised from a string — 4 lines in 3 files

const DEFAULT_KERNEL : []u32 = "[2, 2]";

The string already contains a literal of the right shape, so unquoting is the whole fix. avgpool2d_layer now runs 6 tests.

Neither shows up in zig ast-check: 290 valid and 594 errors are unchanged, because these are semantic, not syntactic. That is the third instrument earning its place.

The keyword field-name fix: correct, and reverted

specs/tools/schema.t27 declares a JSON-Schema record with a field literally named enum. The parser accepted a field name only when the token kind was Ident, so the name was dropped and the element type became the field name — any: void. 23 such fields across 21 specs, 22 of them enum.

Fixing it is one line, with the colon as discriminator so enum ErrorCode { in the braced dialect is not mistaken for a field. It emits @"enum": ?[any] correctly.

And it costs 5 specs. bson, msgpack, async_stream, sort, color went 0 errors → 1, valid 290 → 285.

The reason is the entanglement with #2710: those five contain enum : [Ascending, Descending], the damaged shape that means an enum. Today the field name is dropped, and the leftover bracket list is emitted as Ascending: void, Descending: void — a struct that compiles and satisfies the pinning tests. Preserving the field name emits @"enum": [Ascending,Descending], which is not a type.

So the current passing state of those five depends on a name being thrown away. Both available fixes break them: rewriting the shape to an enum (refuted in #2710 by 27 use sites) and preserving the field name (this). The 23 keyword fields cannot be repaired until enum : [A, B] has an owner's answer.

Reverted with git checkout HEAD -- and rebuilt; 290 / 594 confirmed restored before continuing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions