Skip to content

gen-zig: an @extern body is written as @extern("sym"), which Zig refuses, so a host spec never runs its tests under t27c #11282

Closed as not planned

Description

@gHashTag

What

t27c gen writes a fn whose body is return @extern("getpid"); into Zig verbatim. Zig's @extern takes two arguments (a pointer type and an options struct), so the generated file does not compile, and t27c test-report reports the whole spec BLOCKED, its pure tests included.

Repro (t27c 0.5.2, master 1679c55)

module ExternRepro;

fn host_getpid() -> i32 { return @extern("getpid"); }

fn twice(x: i32) -> i32 { return x * 2; }

test twice_doubles {
    assert twice(2) == 4;
}

t27c test-report specs/repro/extern_repro.t27 --specs-dir specs prints BLOCKED does not compile: spec.zig:19:12: error: expected 2 arguments, found 1; line 19 of the generated Zig is return @extern("getpid");.

Where it bites

What done looks like

  • gen-zig lowers a fn whose body is a single @extern("sym") to a Zig extern declaration with the fn's own parameter and return types, called from the fn, so the module compiles and its pure tests run. Zig links an extern only when a reached call needs it.
  • The repro above reports twice_doubles passed, vacuous passes 0.
  • glass_window.t27, keys_host.t27, keys_probe.t27 and pty_server.t27 are no longer BLOCKED under t27c test-report on the Linux runner (a test that calls a Darwin-only extern would still fail to link there, which is the right report).

Boundary

The gen-zig emitter in bootstrap/src/compiler.rs (frozen core, the FROZEN_HASH rule applies) or its .t27 port. Related: #10295 (host fn declarations for gen-js and gen-ts), #10902 (t27b lowering of @extern), compiler defects tracked on #5980.

🤖 Generated with Claude Code

Activity

  1. added
    shape-refusedClosed by the issue-shape gate (specs/policy/issue_shape.t27); a passing edit reopens it
    on Oct 20, 2026
  2. github-actions commented on Oct 20, 2026

    @github-actions
    Contributor

    Closed by the issue-shape gate (specs/policy/issue_shape.t27, #7498): an issue must have the template's sections. Edit the body; an edit that passes reopens it.

    • missing: ## User Scenarios -- at least one Given/When/Then scenario
    • missing: ## Requirements -- numbered obligations, FR-001: ... MUST ...
    • missing: ## Success Criteria -- an outcome a machine can settle: a number with a unit, a backticked file, exit 0, or a backticked command
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

    shape-refusedClosed by the issue-shape gate (specs/policy/issue_shape.t27); a passing edit reopens it

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions