Skip to content

parser: generic const struct declaration 'pub const Name(T) = struct' does not parse #2162

Description

@gHashTag

Found while repairing corpus damage (#2160), and only observable AFTER that repair: these ten files previously failed earlier in the file for a different reason, which masked this.

$ t27c parse specs/tri/collections/stack.t27   # with the damage repaired
Error: Parse error: parse error at module level near line 13:
Unexpected token in expression: KwStruct ('struct') at line 13:26

Line 13 is pub const Stack(T) = struct {. The parameterised const form is accepted lexically but the parser does not reach struct on the right-hand side.

Ten files, all identical in shape:

file declaration
specs/tri/collections/btree.t27 pub const BTree(K, V) = struct {
specs/tri/collections/lru.t27 pub const LRU(K, V) = struct {
specs/tri/collections/map.t27 pub const Map(K, V) = struct {
specs/tri/collections/queue.t27 pub const Queue(T) = struct {
specs/tri/collections/ring_buffer.t27 pub const Ring(T) = struct {
specs/tri/collections/skip_list.t27 pub const SkipNode(T) = struct {
specs/tri/collections/stack.t27 pub const Stack(T) = struct {
specs/tri/collections/variant.t27 pub const Variant(T) = struct {
specs/tri/graph/graph.t27 pub const Graph(T) = struct {
specs/tri/pipeline/builder.t27 pub const Builder(T) = struct {

Non-generic pub const Name = struct { parses; the difference is the parameter list.

Reproduce: tri damage-repair --combined --apply-to /tmp/repaired_all, then parse the files above from that tree.

Open question before any fix: whether pub const Name(T) = struct is intended surface syntax at all, or whether the corpus is using a form the language never adopted. Ten files using it consistently is evidence of intent but not a specification. That decision belongs to the language owner and it determines whether this is a parser bug or a corpus issue.

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