Skip to content

fix(t27c): read a dotted module name and use path whole - #6102

Merged
gHashTag merged 2 commits into
masterfrom
claude/parse-dotted-module
Oct 5, 2026
Merged

gHashTag merged 2 commits into
masterfrom
claude/parse-dotted-module

Conversation

@gHashTag

@gHashTag gHashTag commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Summary

module sandbox.health; parsed as the module sandbox followed by a stray top-level StmtExpr .health with line 0, and use std.testing; as the import std followed by .testing. Twelve specs were affected. The t27b corpus run found it.

  • Parser (Parser::parse, the module-header skip and use-path loop in parse_module_body):

    • A dotted module header now keeps the whole name verbatim (sandbox.health, port::trinity.src.tri.gen_image). That is the same string extract_module_name already gave the seal tool.
    • A dotted use path is stored as the :: path (sandbox::session_timeout), named after its last segment.
    • A . counts as part of the name only when an identifier follows it. A . inside a body is untouched.
  • Names that become identifiers are sanitized:

    • C include guard (gen_c)
    • HIR Verilog module line (AstToHir::convert)
    • gen-testbench DUT (main.rs run_gen_testbench)

    The AST Verilog path already sanitized the name.

  • use_resolve::use_targets now splits a dotted path the same way it splits a :: path.

  • Zig: a use whose name is also bound as a parameter or local is no longer imported. This is needed because of the fix itself: once use sandbox.session; is named session, it collides with the session parameter in orphan_detection.t27, and Zig rejects a local that shadows a container @import.

Before / after (the 12 specs)

backend before after
Zig header // Generated from t27 spec: sandbox; uses named sandbox/std header sandbox.health; uses named session_timeout/testing; no shadowed @import
C #ifndef SANDBOX_H #ifndef SANDBOX_HEALTH_H
Verilog (AST) module sandbox ( plus always @(*) begin health; session_timeout; session; end (not Verilog) module sandbox_health (, no stray statements
Verilog (HIR) module sandbox ( module sandbox_health (
testbench DUT sandbox DUT sandbox_health
Rust unchanged unchanged

t27c gen specs/sandbox/health.t27 (the path route, through use_resolve) now pulls Session, SessionStatus and Timestamp from session_timeout.t27. Before, it looked for specs/sandbox.session_timeout.t27 and pulled nothing. orphan_detection.t27 Zig passes zig test 6/6 before and after.

Corpus / seal / suite

  • Generated-code hashes: compared master and branch across all 1187 specs/**.t27 and the 113 other .t27 files. Hashes changed for exactly 14 files:
    • the 12 specs above
    • specs/igla/coder/benchmark.t27 and compiler/cli/gen.t27: the Zig guard drops the same shadowed import (dataset, testgen). Both still fail zig test on unrelated undeclared identifiers, as they did before.
  • Stray StmtExpr and parse failures:
    • Specs with a line-0 stray StmtExpr: 15 before, 3 after. The 3 left are unrelated.
    • Parse failures: 12 before, 12 after.
  • Seals: 20 seal files resealed with t27c seal --save, no --force. The four specs/port specs have no seal.
    • tools/check_seal_currency.py: 0 stale.
    • tools/check_seal_coverage.py: OK (1449 seals).
  • Suite: t27c suite --repo-root . reports TOTAL FAILURES 662 before and after, PRIMARY corpus 95 and 95, and an identical JSON summary. This was measured on the pre-rebase base.

Tests

bootstrap/tests/dotted_module_name.rs has 9 cases, including a field-access negative control and a qualified-call control for the import guard. Run against the unfixed binary, all 8 parser and backend cases fail. cargo test --release -p t27c before the rebase: 2816 passed, 0 failed.

Not done

The C guard of a :: module name (137 specs) still contains ::. Fixing it moves 137 seals, so it belongs in its own change.

Closes #5978. Part of #5905.

🤖 Generated with Claude Code

`module sandbox.health;` parsed as the module `sandbox` plus a stray
top-level `.health` expression with line 0, and `use std.testing;` as
the import `std` plus `.testing`. Twelve specs hit it (t27b corpus run).

- parser: the module header keeps the dotted name verbatim (the string
  extract_module_name already gave the seal tool); a dotted use path is
  stored as the `::` path, named for its last segment
- C include guard, HIR Verilog module line and gen-testbench DUT
  sanitize the name; AST gen-verilog no longer emits
  `always @(*) begin health; end`
- use_resolve splits a dotted use path like a `::` one
- Zig: a use whose name is bound as a parameter or local is not
  imported (orphan_detection.t27's `session` parameter shadowed the
  new `session` import)
- 20 seal files resealed for 14 specs; suite unchanged (662/662)

Closes #5978. Part of #5905.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gHashTag
gHashTag force-pushed the claude/parse-dotted-module branch from f39af24 to d6d1783 Compare October 4, 2026 16:20
This was referenced Oct 4, 2026
This was referenced Oct 5, 2026
@gHashTag
gHashTag merged commit 682564f into master Oct 5, 2026
32 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

t27c parser: dotted module name / use path leaves a stray top-level expression (12 specs)

1 participant