aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-08-09 10:09:38 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-08-09 10:09:38 -0400
commit35d3444e2742faa3c2e805cdcbfeceaf0287eefc (patch)
tree408182308c5f962660f200c59b2619be8d194ffc /test/compile_errors.zig
parent54675b060ae6139f60e111521b9a2688f66977a0 (diff)
downloadzig-35d3444e2742faa3c2e805cdcbfeceaf0287eefc.tar.gz
zig-35d3444e2742faa3c2e805cdcbfeceaf0287eefc.zip
more intuitive left shift and right shift operators
Before: * << is left shift, not allowed to shift 1 bits out * <<% is left shift, allowed to shift 1 bits out * >> is right shift, allowed to shift 1 bits out After: * << is left shift, allowed to shift 1 bits out * >> is right shift, allowed to shift 1 bits out * @shlExact is left shift, not allowed to shift 1 bits out * @shrExact is right shift, not allowed to shift 1 bits out Closes #413
Diffstat (limited to 'test/compile_errors.zig')
-rw-r--r--test/compile_errors.zig14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 07dafdbeb0..358569d0ef 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -1959,4 +1959,18 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
\\}
,
".tmp_source.zig:2:15: error: expected pointer, found 'i32'");
+
+ cases.add("@shlExact shifts out 1 bits",
+ \\comptime {
+ \\ const x = @shlExact(u8(0b01010101), 2);
+ \\}
+ ,
+ ".tmp_source.zig:2:15: error: operation caused overflow");
+
+ cases.add("@shrExact shifts out 1 bits",
+ \\comptime {
+ \\ const x = @shrExact(u8(0b10101010), 2);
+ \\}
+ ,
+ ".tmp_source.zig:2:15: error: exact shift shifted out 1 bits");
}