Skip to content

Commit 264bd70

Browse files
JackoCooliomlugg
andcommitted
Sema: remove incorrect requireRuntimeBlock calls
Part of #22353 Resolves: #24273 Co-Authored-By: Matthew Lugg <[email protected]>
1 parent ac1e73e commit 264bd70

File tree

3 files changed

+30
-12
lines changed

3 files changed

+30
-12
lines changed

src/Sema.zig

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19572,19 +19572,14 @@ fn structInitAnon(
1957219572
try sema.declareDependency(.{ .interned = struct_ty });
1957319573
try sema.addTypeReferenceEntry(src, struct_ty);
1957419574

19575-
const runtime_index = opt_runtime_index orelse {
19575+
_ = opt_runtime_index orelse {
1957619576
const struct_val = try pt.intern(.{ .aggregate = .{
1957719577
.ty = struct_ty,
1957819578
.storage = .{ .elems = values },
1957919579
} });
1958019580
return sema.addConstantMaybeRef(struct_val, is_ref);
1958119581
};
1958219582

19583-
try sema.requireRuntimeBlock(block, LazySrcLoc.unneeded, block.src(.{ .init_elem = .{
19584-
.init_node_offset = src.offset.node_offset.x,
19585-
.elem_index = @intCast(runtime_index),
19586-
} }));
19587-
1958819583
if (is_ref) {
1958919584
const target = zcu.getTarget();
1959019585
const alloc_ty = try pt.ptrTypeSema(.{
@@ -19713,7 +19708,7 @@ fn zirArrayInit(
1971319708
if (!comptime_known) break @intCast(i);
1971419709
} else null;
1971519710

19716-
const runtime_index = opt_runtime_index orelse {
19711+
_ = opt_runtime_index orelse {
1971719712
const elem_vals = try sema.arena.alloc(InternPool.Index, resolved_args.len);
1971819713
for (elem_vals, resolved_args) |*val, arg| {
1971919714
// We checked that all args are comptime above.
@@ -19728,11 +19723,6 @@ fn zirArrayInit(
1972819723
return sema.addConstantMaybeRef(result_val.toIntern(), is_ref);
1972919724
};
1973019725

19731-
try sema.requireRuntimeBlock(block, LazySrcLoc.unneeded, block.src(.{ .init_elem = .{
19732-
.init_node_offset = src.offset.node_offset.x,
19733-
.elem_index = runtime_index,
19734-
} }));
19735-
1973619726
if (is_ref) {
1973719727
const target = zcu.getTarget();
1973819728
const alloc_ty = try pt.ptrTypeSema(.{
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
fn comptimeArray(comptime _: []const u8) void {}
2+
fn bar() u8 {
3+
return 123;
4+
}
5+
export fn entry() void {
6+
const y = bar();
7+
comptimeArray(&.{y});
8+
}
9+
10+
// error
11+
//
12+
// :7:19: error: unable to resolve comptime value
13+
// :7:19: note: argument to comptime parameter must be comptime-known
14+
// :1:18: note: parameter declared comptime here
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
fn comptimeStruct(comptime _: anytype) void {}
2+
fn bar() u8 {
3+
return 123;
4+
}
5+
export fn entry() void {
6+
const y = bar();
7+
comptimeStruct(.{ .foo = y });
8+
}
9+
10+
// error
11+
//
12+
// :7:21: error: unable to resolve comptime value
13+
// :7:21: note: argument to comptime parameter must be comptime-known
14+
// :1:19: note: parameter declared comptime here

0 commit comments

Comments
 (0)