| author | |
| committer | |
| log | 9181ecd95133b42da75c6c5e8456830d93a9f7a9 |
| tree | 5215d467bf8cdefc366efdfce018e7978361b13d |
| parent | 129de47a71b954b1118ce188f7032ad726491f53 |
3 files changed, 18 insertions(+), 4 deletions(-)
lib/std/math/nextafter.zig+1-1| ... | ... | @@ -144,7 +144,7 @@ test "int" { |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | test "float" { |
| 147 | @setEvalBranchQuota(2000); | |
| 147 | @setEvalBranchQuota(3000); | |
| 148 | 148 | |
| 149 | 149 | // normal -> normal |
| 150 | 150 | try expect(nextAfter(f16, 0x1.234p0, 2.0) == 0x1.238p0); |
src/Sema.zig+3-3| ... | ... | @@ -7525,10 +7525,12 @@ fn analyzeCall( |
| 7525 | 7525 | |
| 7526 | 7526 | var is_generic_call = func_ty_info.is_generic; |
| 7527 | 7527 | var is_comptime_call = block.is_comptime or modifier == .compile_time; |
| 7528 | var is_inline_call = is_comptime_call or modifier == .always_inline or func_ty_info.cc == .Inline; | |
| 7528 | 7529 | var comptime_reason: ?*const Block.ComptimeReason = null; |
| 7529 | if (!is_comptime_call) { | |
| 7530 | if (!is_inline_call and !is_comptime_call) { | |
| 7530 | 7531 | if (sema.typeRequiresComptime(Type.fromInterned(func_ty_info.return_type))) |ct| { |
| 7531 | 7532 | is_comptime_call = ct; |
| 7533 | is_inline_call = ct; | |
| 7532 | 7534 | if (ct) { |
| 7533 | 7535 | comptime_reason = &.{ .comptime_ret_ty = .{ |
| 7534 | 7536 | .block = block, |
| ... | ... | @@ -7542,8 +7544,6 @@ fn analyzeCall( |
| 7542 | 7544 | else => |e| return e, |
| 7543 | 7545 | } |
| 7544 | 7546 | } |
| 7545 | var is_inline_call = is_comptime_call or modifier == .always_inline or | |
| 7546 | func_ty_info.cc == .Inline; | |
| 7547 | 7547 | |
| 7548 | 7548 | if (sema.func_is_naked and !is_inline_call and !is_comptime_call) { |
| 7549 | 7549 | const msg = msg: { |
test/behavior/fn.zig+14| ... | ... | @@ -604,3 +604,17 @@ test "comptime parameters don't have to be marked comptime if only called at com |
| 604 | 604 | }; |
| 605 | 605 | comptime std.debug.assert(S.foo(5, 6) == 11); |
| 606 | 606 | } |
| 607 | ||
| 608 | test "inline function with comptime-known comptime-only return type called at runtime" { | |
| 609 | const S = struct { | |
| 610 | inline fn foo(x: *i32, y: *const i32) type { | |
| 611 | x.* = y.*; | |
| 612 | return f32; | |
| 613 | } | |
| 614 | }; | |
| 615 | var a: i32 = 0; | |
| 616 | const b: i32 = 111; | |
| 617 | const T = S.foo(&a, &b); | |
| 618 | try expectEqual(111, a); | |
| 619 | try expectEqual(f32, T); | |
| 620 | } |