Merge pull request #24448 from matklad/matklad/inline

langref: make example more interesting.
This commit is contained in:
Andrew Kelley 2025-07-15 08:51:56 +02:00 committed by GitHub
commit d3cd0b2714
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View file

@ -1,8 +1,7 @@
const std = @import("std");
const expect = std.testing.expect;
const print = std.debug.print;
test "defer unwinding" {
pub fn main() void {
print("\n", .{});
defer {
@ -19,4 +18,4 @@ test "defer unwinding" {
}
}
// test
// exe=succeed

View file

@ -1,11 +1,14 @@
test "inline function call" {
const std = @import("std");
pub fn main() void {
if (foo(1200, 34) != 1234) {
@compileError("bad");
}
}
inline fn foo(a: i32, b: i32) i32 {
std.debug.print("runtime a = {} b = {}", .{ a, b });
return a + b;
}
// test
// exe=succeed