diff options
| author | Jimmi Holst Christensen <jimmiholstchristensen@gmail.com> | 2018-11-13 05:08:37 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-13 05:08:37 -0800 |
| commit | 8139c5a516eaa217ed76acdf09496895451c5c5c (patch) | |
| tree | 89841cec818c5650471c7f2c11141013f8640bf7 /test/runtime_safety.zig | |
| parent | 67fbb0434f7104801c66e821b5057a8323e377df (diff) | |
| download | zig-8139c5a516eaa217ed76acdf09496895451c5c5c.tar.gz zig-8139c5a516eaa217ed76acdf09496895451c5c5c.zip | |
New Zig formal grammar (#1685)
Reverted #1628 and changed the grammar+parser of the language to not allow certain expr where types are expected
Diffstat (limited to 'test/runtime_safety.zig')
| -rw-r--r-- | test/runtime_safety.zig | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/test/runtime_safety.zig b/test/runtime_safety.zig index 942ef16402..343b3ff592 100644 --- a/test/runtime_safety.zig +++ b/test/runtime_safety.zig @@ -5,7 +5,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { \\ @import("std").os.exit(126); \\} - \\const Foo = enum.{ + \\const Foo = enum { \\ A, \\ B, \\ C, @@ -72,7 +72,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ @import("std").os.exit(126); \\} \\pub fn main() void { - \\ const a = []i32.{1, 2, 3, 4}; + \\ const a = []i32{1, 2, 3, 4}; \\ baz(bar(a)); \\} \\fn bar(a: []const i32) i32 { @@ -228,7 +228,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ @import("std").os.exit(126); \\} \\pub fn main() !void { - \\ const x = widenSlice([]u8.{1, 2, 3, 4, 5}); + \\ const x = widenSlice([]u8{1, 2, 3, 4, 5}); \\ if (x.len == 0) return error.Whatever; \\} \\fn widenSlice(slice: []align(1) const u8) []align(1) const i32 { @@ -297,7 +297,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\pub fn main() void { \\ _ = bar(9999); \\} - \\fn bar(x: u16) error { + \\fn bar(x: u16) anyerror { \\ return @intToError(x); \\} ); @@ -306,8 +306,8 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\pub fn panic(message: []const u8, stack_trace: ?*@import("builtin").StackTrace) noreturn { \\ @import("std").os.exit(126); \\} - \\const Set1 = error.{A, B}; - \\const Set2 = error.{A, C}; + \\const Set1 = error{A, B}; + \\const Set2 = error{A, C}; \\pub fn main() void { \\ _ = foo(Set1.B); \\} @@ -321,7 +321,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ @import("std").os.exit(126); \\} \\pub fn main() !void { - \\ var array align(4) = []u32.{0x11111111, 0x11111111}; + \\ var array align(4) = []u32{0x11111111, 0x11111111}; \\ const bytes = @sliceToBytes(array[0..]); \\ if (foo(bytes) != 0x11111111) return error.Wrong; \\} @@ -337,13 +337,13 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ @import("std").os.exit(126); \\} \\ - \\const Foo = union.{ + \\const Foo = union { \\ float: f32, \\ int: u32, \\}; \\ \\pub fn main() void { - \\ var f = Foo.{ .int = 42 }; + \\ var f = Foo { .int = 42 }; \\ bar(&f); \\} \\ @@ -368,16 +368,16 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { \\ cancel p2; \\} \\ - \\fn nonFailing() promise->error!void { + \\fn nonFailing() promise->anyerror!void { \\ return async<std.debug.global_allocator> failing() catch unreachable; \\} \\ - \\async fn failing() error!void { + \\async fn failing() anyerror!void { \\ suspend; \\ return error.Fail; \\} \\ - \\async fn printTrace(p: promise->error!void) void { + \\async fn printTrace(p: promise->anyerror!void) void { \\ (await p) catch unreachable; \\} ); |
