aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors
diff options
context:
space:
mode:
authoryujiri8 <yujiri@disroot.org>2023-05-31 07:15:52 -0400
committerGitHub <noreply@github.com>2023-05-31 11:15:52 +0000
commitcd1417dbdf098634641e87dba4c3be2806d76250 (patch)
tree86f37e2015cb84fd08ec260772b7bb6b40686811 /test/cases/compile_errors
parent32e719e070067333efa9d4888927b425d118fc97 (diff)
downloadzig-cd1417dbdf098634641e87dba4c3be2806d76250.tar.gz
zig-cd1417dbdf098634641e87dba4c3be2806d76250.zip
don't crash when can't evaluate comptime expression with inferred type
Closes #15911.
Diffstat (limited to 'test/cases/compile_errors')
-rw-r--r--test/cases/compile_errors/unable_to_evaluate_comptime_expr_with_inferred_type.zig17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/cases/compile_errors/unable_to_evaluate_comptime_expr_with_inferred_type.zig b/test/cases/compile_errors/unable_to_evaluate_comptime_expr_with_inferred_type.zig
new file mode 100644
index 0000000000..3792cf2f82
--- /dev/null
+++ b/test/cases/compile_errors/unable_to_evaluate_comptime_expr_with_inferred_type.zig
@@ -0,0 +1,17 @@
+const A = struct {
+ a: u8,
+};
+
+var n: u8 = 5;
+var a: A = .{ .a = n };
+
+pub export fn entry() void {
+ _ = a;
+}
+
+// error
+// backend=stage2
+// target=native
+//
+// :6:13: error: unable to evaluate comptime expression
+// :6:16: note: operation is runtime due to this operand