Skip to content

ability to @import .zon files #14531

Closed
Closed
@andrewrk

Description

@andrewrk

Extracted from #14523.

Given a foo.zon file:

.{
    .bar = "hello",
}

it should be possible to @import it as a comptime-known value:

const data = @import("foo.zon");
comptime {
    assert(std.mem.eql(u8, data.bar, "hello"));
}

One motivating use case in particular is, inside build.zig, one should be able to @import("build.zig.zon") and access those values.

Note that the top level expression of a zon file is not necessarily an anonymous struct literal. It can be:

  • string literal
  • boolean literal
  • integer literal
  • null literal
  • undefined literal
  • anonymous struct literal
  • tuple literal
  • anonymous enum literal

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSolving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions