From 77678b2cbc7ac9ba2d5d4725241f6a9f7ac64fa4 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 10 Jun 2018 01:13:51 -0400 Subject: [PATCH] breaking syntax change: orelse keyword instead of ?? (#1096) use the `zig-fmt-optional-default` branch to have zig fmt automatically do the changes. closes #1023 --- build.zig | 6 ++--- doc/docgen.zig | 6 ++--- doc/langref.html.in | 16 ++++++------ src-self-hosted/main.zig | 14 +++++------ src-self-hosted/module.zig | 8 +++--- src/all_types.hpp | 7 +++++- src/analyze.cpp | 1 + src/ast_render.cpp | 12 +++++++-- src/ir.cpp | 31 ++++++++++-------------- src/parser.cpp | 13 +++++----- src/tokenizer.cpp | 27 +++++---------------- src/tokenizer.hpp | 2 +- src/translate_c.cpp | 16 ++++++------ std/atomic/queue.zig | 4 +-- std/atomic/stack.zig | 4 +-- std/buf_map.zig | 6 ++--- std/buf_set.zig | 4 +-- std/build.zig | 24 +++++++++--------- std/debug/index.zig | 20 +++++++-------- std/heap.zig | 10 ++++---- std/linked_list.zig | 4 +-- std/os/index.zig | 14 +++++------ std/os/linux/vdso.zig | 8 +++--- std/os/path.zig | 12 ++++----- std/os/windows/util.zig | 2 +- std/special/build_runner.zig | 10 ++++---- std/unicode.zig | 2 +- std/zig/parse.zig | 47 ++++++++++++++++++------------------ std/zig/render.zig | 8 +++--- test/cases/cast.zig | 6 ++--- test/cases/null.zig | 10 ++++---- test/compile_errors.zig | 2 +- test/translate_c.zig | 20 +++++++-------- 33 files changed, 187 insertions(+), 189 deletions(-) diff --git a/build.zig b/build.zig index eada37816c..fd154c7504 100644 --- a/build.zig +++ b/build.zig @@ -102,11 +102,11 @@ pub fn build(b: *Builder) !void { b.default_step.dependOn(&exe.step); - const skip_self_hosted = b.option(bool, "skip-self-hosted", "Main test suite skips building self hosted compiler") ?? false; + const skip_self_hosted = b.option(bool, "skip-self-hosted", "Main test suite skips building self hosted compiler") orelse false; if (!skip_self_hosted) { test_step.dependOn(&exe.step); } - const verbose_link_exe = b.option(bool, "verbose-link", "Print link command for self hosted compiler") ?? false; + const verbose_link_exe = b.option(bool, "verbose-link", "Print link command for self hosted compiler") orelse false; exe.setVerboseLink(verbose_link_exe); b.installArtifact(exe); @@ -114,7 +114,7 @@ pub fn build(b: *Builder) !void { installCHeaders(b, c_header_files); const test_filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter"); - const with_lldb = b.option(bool, "with-lldb", "Run tests in LLDB to get a backtrace if one fails") ?? false; + const with_lldb = b.option(bool, "with-lldb", "Run tests in LLDB to get a backtrace if one fails") orelse false; test_step.dependOn(docs_step); diff --git a/doc/docgen.zig b/doc/docgen.zig index ed0e1be273..3283d146b0 100644 --- a/doc/docgen.zig +++ b/doc/docgen.zig @@ -25,13 +25,13 @@ pub fn main() !void { if (!args_it.skip()) @panic("expected self arg"); - const zig_exe = try (args_it.next(allocator) ?? @panic("expected zig exe arg")); + const zig_exe = try (args_it.next(allocator) orelse @panic("expected zig exe arg")); defer allocator.free(zig_exe); - const in_file_name = try (args_it.next(allocator) ?? @panic("expected input arg")); + const in_file_name = try (args_it.next(allocator) orelse @panic("expected input arg")); defer allocator.free(in_file_name); - const out_file_name = try (args_it.next(allocator) ?? @panic("expected output arg")); + const out_file_name = try (args_it.next(allocator) orelse @panic("expected output arg")); defer allocator.free(out_file_name); var in_file = try os.File.openRead(allocator, in_file_name); diff --git a/doc/langref.html.in b/doc/langref.html.in index 4c4a637095..0ada8a5196 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -985,7 +985,7 @@ a ^= b -
a ?? b
+
a orelse b