aboutsummaryrefslogtreecommitdiff
path: root/test/cases/recursive_inline_function.1.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-07-01 15:52:54 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-07-01 15:52:54 -0700
commitc89dd15e1be4959800dc7092d7dd4375253db7bc (patch)
treeca184ae53592efa21e67128a5f891d642d7f1118 /test/cases/recursive_inline_function.1.zig
parent5466e87fce581f2ef90ac23bb80b1dbc05836fc6 (diff)
parent2360f8c490f3ec684ed64ff28e8c1fade249070b (diff)
downloadzig-c89dd15e1be4959800dc7092d7dd4375253db7bc.tar.gz
zig-c89dd15e1be4959800dc7092d7dd4375253db7bc.zip
Merge remote-tracking branch 'origin/master' into llvm14
Diffstat (limited to 'test/cases/recursive_inline_function.1.zig')
-rw-r--r--test/cases/recursive_inline_function.1.zig19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/cases/recursive_inline_function.1.zig b/test/cases/recursive_inline_function.1.zig
new file mode 100644
index 0000000000..8ed9bde8e8
--- /dev/null
+++ b/test/cases/recursive_inline_function.1.zig
@@ -0,0 +1,19 @@
+// This additionally tests that the compile error reports the correct source location.
+// Without storing source locations relative to the owner decl, the compile error
+// here would be off by 2 bytes (from the "7" -> "999").
+pub fn main() void {
+ const y = fibonacci(999);
+ if (y - 21 != 0) unreachable;
+}
+
+inline fn fibonacci(n: usize) usize {
+ if (n <= 2) return n;
+ return fibonacci(n - 2) + fibonacci(n - 1);
+}
+
+// error
+//
+// :11:21: error: evaluation exceeded 1000 backwards branches
+// :11:40: note: called from here (6 times)
+// :11:21: note: called from here (495 times)
+// :5:24: note: called from here