diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-12-22 00:50:30 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-12-22 00:50:30 -0500 |
| commit | d917815d8111b98dc237cbe2c723fa63018e02b1 (patch) | |
| tree | ce12771a86b2412ee9692ca73d3ca49abe5da3ce /test/cases/error.zig | |
| parent | 8bc523219c66427951e5339550502871547f2138 (diff) | |
| download | zig-d917815d8111b98dc237cbe2c723fa63018e02b1.tar.gz zig-d917815d8111b98dc237cbe2c723fa63018e02b1.zip | |
explicitly return from blocks
instead of last statement being expression value
closes #629
Diffstat (limited to 'test/cases/error.zig')
| -rw-r--r-- | test/cases/error.zig | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/test/cases/error.zig b/test/cases/error.zig index 9e55f57b6d..3974e9dc7c 100644 --- a/test/cases/error.zig +++ b/test/cases/error.zig @@ -3,7 +3,7 @@ const mem = @import("std").mem; pub fn foo() -> %i32 { const x = %return bar(); - return x + 1 + return x + 1; } pub fn bar() -> %i32 { @@ -21,7 +21,7 @@ test "error wrapping" { error ItBroke; fn gimmeItBroke() -> []const u8 { - @errorName(error.ItBroke) + return @errorName(error.ItBroke); } test "@errorName" { @@ -48,7 +48,7 @@ error AnError; error AnError; error SecondError; fn shouldBeNotEqual(a: error, b: error) { - if (a == b) unreachable + if (a == b) unreachable; } @@ -60,11 +60,7 @@ test "error binary operator" { } error ItBroke; fn errBinaryOperatorG(x: bool) -> %isize { - if (x) { - error.ItBroke - } else { - isize(10) - } + return if (x) error.ItBroke else isize(10); } @@ -72,7 +68,7 @@ test "unwrap simple value from error" { const i = %%unwrapSimpleValueFromErrorDo(); assert(i == 13); } -fn unwrapSimpleValueFromErrorDo() -> %isize { 13 } +fn unwrapSimpleValueFromErrorDo() -> %isize { return 13; } test "error return in assignment" { |
