mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
Sema: remove incorrect requireRuntimeBlock calls
Part of #22353 Resolves: #24273 Co-Authored-By: Matthew Lugg <mlugg@mlugg.co.uk>
This commit is contained in:
parent
ac1e73e249
commit
264bd7053e
14
src/Sema.zig
14
src/Sema.zig
@ -19572,7 +19572,7 @@ fn structInitAnon(
|
||||
try sema.declareDependency(.{ .interned = struct_ty });
|
||||
try sema.addTypeReferenceEntry(src, struct_ty);
|
||||
|
||||
const runtime_index = opt_runtime_index orelse {
|
||||
_ = opt_runtime_index orelse {
|
||||
const struct_val = try pt.intern(.{ .aggregate = .{
|
||||
.ty = struct_ty,
|
||||
.storage = .{ .elems = values },
|
||||
@ -19580,11 +19580,6 @@ fn structInitAnon(
|
||||
return sema.addConstantMaybeRef(struct_val, is_ref);
|
||||
};
|
||||
|
||||
try sema.requireRuntimeBlock(block, LazySrcLoc.unneeded, block.src(.{ .init_elem = .{
|
||||
.init_node_offset = src.offset.node_offset.x,
|
||||
.elem_index = @intCast(runtime_index),
|
||||
} }));
|
||||
|
||||
if (is_ref) {
|
||||
const target = zcu.getTarget();
|
||||
const alloc_ty = try pt.ptrTypeSema(.{
|
||||
@ -19713,7 +19708,7 @@ fn zirArrayInit(
|
||||
if (!comptime_known) break @intCast(i);
|
||||
} else null;
|
||||
|
||||
const runtime_index = opt_runtime_index orelse {
|
||||
_ = opt_runtime_index orelse {
|
||||
const elem_vals = try sema.arena.alloc(InternPool.Index, resolved_args.len);
|
||||
for (elem_vals, resolved_args) |*val, arg| {
|
||||
// We checked that all args are comptime above.
|
||||
@ -19728,11 +19723,6 @@ fn zirArrayInit(
|
||||
return sema.addConstantMaybeRef(result_val.toIntern(), is_ref);
|
||||
};
|
||||
|
||||
try sema.requireRuntimeBlock(block, LazySrcLoc.unneeded, block.src(.{ .init_elem = .{
|
||||
.init_node_offset = src.offset.node_offset.x,
|
||||
.elem_index = runtime_index,
|
||||
} }));
|
||||
|
||||
if (is_ref) {
|
||||
const target = zcu.getTarget();
|
||||
const alloc_ty = try pt.ptrTypeSema(.{
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
fn comptimeArray(comptime _: []const u8) void {}
|
||||
fn bar() u8 {
|
||||
return 123;
|
||||
}
|
||||
export fn entry() void {
|
||||
const y = bar();
|
||||
comptimeArray(&.{y});
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :7:19: error: unable to resolve comptime value
|
||||
// :7:19: note: argument to comptime parameter must be comptime-known
|
||||
// :1:18: note: parameter declared comptime here
|
||||
@ -0,0 +1,14 @@
|
||||
fn comptimeStruct(comptime _: anytype) void {}
|
||||
fn bar() u8 {
|
||||
return 123;
|
||||
}
|
||||
export fn entry() void {
|
||||
const y = bar();
|
||||
comptimeStruct(.{ .foo = y });
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :7:21: error: unable to resolve comptime value
|
||||
// :7:21: note: argument to comptime parameter must be comptime-known
|
||||
// :1:19: note: parameter declared comptime here
|
||||
Loading…
x
Reference in New Issue
Block a user