Static locals read from another static's initializer

A function-local static whose initializer reads another local static
(static const int n = min((order + 1) * (order + 1), 9)) failed with
"this variable is not supported yet": initializers are lowered in
functions of their own, where the other static is not a local. It is
its private global there, as a file-scope static is.
This commit is contained in:
Peter Li 2026-11-01 20:16:21 -08:00
parent 2716772d98
commit 0d4837d5fb
1 changed files with 4 additions and 1 deletions

View File

@ -1693,7 +1693,10 @@ const Lowerer = struct {
const t = l.types(); const t = l.types();
if (l.vars.get(v)) |p| return p; if (l.vars.get(v)) |p| return p;
switch (v.storage) { switch (v.storage) {
.local, .param, .local_static => return l.fail(e, "this variable"), .local, .param => return l.fail(e, "this variable"),
// Not yet in `vars` only inside another static's initializer:
// its global, as for a file-scope static.
.local_static => {},
.global_uniform, .cbuffer => { .global_uniform, .cbuffer => {
if (isObject(&l.s.types, v.type)) { if (isObject(&l.s.types, v.type)) {
l.unsupported(e.loc, "resource '{s}' declared as a uniform is not supported yet", .{v.name}); l.unsupported(e.loc, "resource '{s}' declared as a uniform is not supported yet", .{v.name});