aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-06-13 11:04:09 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-06-13 11:04:09 -0400
commit8dd24796c43b5241a5dcd5508e4be00483ebc25b (patch)
tree7946e31a2aff825ee4016ed1f5be46df64726b0b /test/compile_errors.zig
parent86adc1ef39ed12ebe9eb6d3b7cf8eea481dd060d (diff)
downloadzig-8dd24796c43b5241a5dcd5508e4be00483ebc25b.tar.gz
zig-8dd24796c43b5241a5dcd5508e4be00483ebc25b.zip
disallow implicit casts that break rules for optionals
closes #1102
Diffstat (limited to 'test/compile_errors.zig')
-rw-r--r--test/compile_errors.zig13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 5ec2759032..06f17a37ee 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -2,6 +2,19 @@ const tests = @import("tests.zig");
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
+ "use implicit casts to assign null to non-nullable pointer",
+ \\export fn entry() void {
+ \\ var x: i32 = 1234;
+ \\ var p: *i32 = &x;
+ \\ var pp: *?*i32 = &p;
+ \\ pp.* = null;
+ \\ var y = p.*;
+ \\}
+ ,
+ ".tmp_source.zig:4:23: error: expected type '*?*i32', found '**i32'",
+ );
+
+ cases.add(
"attempted implicit cast from T to [*]const T",
\\export fn entry() void {
\\ const x: [*]const bool = true;