mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 09:02:32 +00:00
Change error when runtime value passed to comptime arg
This commit is contained in:
parent
129ccad434
commit
a39d3155b4
@ -20068,6 +20068,11 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
|
||||
|
||||
ZigValue *arg_val;
|
||||
|
||||
if (comptime_arg && !instr_is_comptime(casted_arg)) {
|
||||
ir_add_error(ira, &casted_arg->base,
|
||||
buf_sprintf("runtime value cannot be passed to comptime arg"));
|
||||
return false;
|
||||
}
|
||||
if (comptime_arg) {
|
||||
arg_part_of_generic_id = true;
|
||||
arg_val = ir_resolve_const(ira, casted_arg, UndefBad);
|
||||
|
@ -5314,7 +5314,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
\\
|
||||
\\export fn entry() usize { return @sizeOf(@TypeOf(test1)); }
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:3:16: error: unable to evaluate constant expression",
|
||||
"tmp.zig:3:16: error: runtime value cannot be passed to comptime arg",
|
||||
});
|
||||
|
||||
cases.add("assign null to non-optional pointer",
|
||||
|
Loading…
Reference in New Issue
Block a user