From 76ab1d2b6c9eedd861920ae6b6f8ee06aa482159 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 30 Apr 2018 14:20:56 -0400 Subject: support foo.* for ptr deref See #770 --- src/analyze.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/analyze.cpp') diff --git a/src/analyze.cpp b/src/analyze.cpp index 1ecfe32f4c..99712cbfaf 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -3275,6 +3275,7 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) { case NodeTypeUnreachable: case NodeTypeAsmExpr: case NodeTypeFieldAccessExpr: + case NodeTypePtrDeref: case NodeTypeStructField: case NodeTypeContainerInitExpr: case NodeTypeStructValueField: -- cgit v1.2.3 From 43085417bec447ab31f3454e180213f102885cc8 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 24 May 2018 21:27:44 -0400 Subject: update github.com/zig-lang to github.com/ziglang --- README.md | 4 ++-- doc/langref.html.in | 8 ++++---- example/hello_world/hello_libc.zig | 2 +- src/analyze.cpp | 4 ++-- src/codegen.cpp | 6 +++--- src/ir.cpp | 8 ++++---- std/atomic/queue.zig | 2 +- std/event.zig | 8 ++++---- std/fmt/index.zig | 2 +- std/mem.zig | 2 +- std/os/index.zig | 6 +++--- std/os/test.zig | 2 +- std/os/time.zig | 2 +- std/special/compiler_rt/comparetf2.zig | 4 ++-- std/zig/ast.zig | 4 ++-- test/build_examples.zig | 2 +- test/cases/coroutines.zig | 2 +- test/cases/misc.zig | 2 +- test/compare_output.zig | 4 ++-- 19 files changed, 37 insertions(+), 37 deletions(-) (limited to 'src/analyze.cpp') diff --git a/README.md b/README.md index cf4d8179c7..b5bf13f095 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ libc. Create demo games using Zig. ## Building -[![Build Status](https://travis-ci.org/zig-lang/zig.svg?branch=master)](https://travis-ci.org/zig-lang/zig) +[![Build Status](https://travis-ci.org/ziglang/zig.svg?branch=master)](https://travis-ci.org/ziglang/zig) [![Build status](https://ci.appveyor.com/api/projects/status/4t80mk2dmucrc38i/branch/master?svg=true)](https://ci.appveyor.com/project/andrewrk/zig-d3l86/branch/master) ### Stage 1: Build Zig from C++ Source Code @@ -161,7 +161,7 @@ bin/zig build --build-file ../build.zig test ##### Windows -See https://github.com/zig-lang/zig/wiki/Building-Zig-on-Windows +See https://github.com/ziglang/zig/wiki/Building-Zig-on-Windows ### Stage 2: Build Self-Hosted Zig from Zig Source Code diff --git a/doc/langref.html.in b/doc/langref.html.in index c3c50b117b..d63c38d0fe 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -96,7 +96,7 @@

If you search for something specific in this documentation and do not find it, - please file an issue or say something on IRC. + please file an issue or say something on IRC.

The code samples in this document are compiled and tested as part of the main test suite of Zig. @@ -2827,7 +2827,7 @@ test "fn reflection" {

The number of unique error values across the entire compilation should determine the size of the error set type. - However right now it is hard coded to be a u16. See #768. + However right now it is hard coded to be a u16. See #768.

You can implicitly cast an error from a subset to its superset: @@ -5958,7 +5958,7 @@ pub fn main() void { {#code_begin|exe#} {#link_libc#} const c = @cImport({ - // See https://github.com/zig-lang/zig/issues/515 + // See https://github.com/ziglang/zig/issues/515 @cDefine("_NO_CRT_STDIO_INLINE", "1"); @cInclude("stdio.h"); }); @@ -6301,7 +6301,7 @@ fn readU32Be() u32 {}

  • Non-Ascii Unicode line endings: U+0085 (NEL), U+2028 (LS), U+2029 (PS).
  • The codepoint U+000a (LF) (which is encoded as the single-byte value 0x0a) is the line terminator character. This character always terminates a line of zig source code (except possbly the last line of the file).

    -

    For some discussion on the rationale behind these design decisions, see issue #663

    +

    For some discussion on the rationale behind these design decisions, see issue #663

    {#header_close#} {#header_open|Grammar#}
    Root = many(TopLevelItem) EOF
    diff --git a/example/hello_world/hello_libc.zig b/example/hello_world/hello_libc.zig
    index 60123c6fd8..4a35e47b15 100644
    --- a/example/hello_world/hello_libc.zig
    +++ b/example/hello_world/hello_libc.zig
    @@ -1,5 +1,5 @@
     const c = @cImport({
    -    // See https://github.com/zig-lang/zig/issues/515
    +    // See https://github.com/ziglang/zig/issues/515
         @cDefine("_NO_CRT_STDIO_INLINE", "1");
         @cInclude("stdio.h");
         @cInclude("string.h");
    diff --git a/src/analyze.cpp b/src/analyze.cpp
    index d6137a4286..c59fde8ef6 100644
    --- a/src/analyze.cpp
    +++ b/src/analyze.cpp
    @@ -1007,7 +1007,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
         if (fn_type_id->return_type != nullptr) {
             ensure_complete_type(g, fn_type_id->return_type);
         } else {
    -        zig_panic("TODO implement inferred return types https://github.com/zig-lang/zig/issues/447");
    +        zig_panic("TODO implement inferred return types https://github.com/ziglang/zig/issues/447");
         }
     
         TypeTableEntry *fn_type = new_type_table_entry(TypeTableEntryIdFn);
    @@ -1556,7 +1556,7 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
                 return g->builtin_types.entry_invalid;
             }
             add_node_error(g, proto_node,
    -            buf_sprintf("TODO implement inferred return types https://github.com/zig-lang/zig/issues/447"));
    +            buf_sprintf("TODO implement inferred return types https://github.com/ziglang/zig/issues/447"));
             return g->builtin_types.entry_invalid;
             //return get_generic_fn_type(g, &fn_type_id);
         }
    diff --git a/src/codegen.cpp b/src/codegen.cpp
    index f1e102392a..69542b3e67 100644
    --- a/src/codegen.cpp
    +++ b/src/codegen.cpp
    @@ -582,7 +582,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {
                 addLLVMArgAttr(fn_table_entry->llvm_value, (unsigned)gen_index, "nonnull");
             }
             // Note: byval is disabled on windows due to an LLVM bug:
    -        // https://github.com/zig-lang/zig/issues/536
    +        // https://github.com/ziglang/zig/issues/536
             if (is_byval && g->zig_target.os != OsWindows) {
                 addLLVMArgAttr(fn_table_entry->llvm_value, (unsigned)gen_index, "byval");
             }
    @@ -3067,7 +3067,7 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
         for (size_t param_i = 0; param_i < fn_type_id->param_count; param_i += 1) {
             FnGenParamInfo *gen_info = &fn_type->data.fn.gen_param_info[param_i];
             // Note: byval is disabled on windows due to an LLVM bug:
    -        // https://github.com/zig-lang/zig/issues/536
    +        // https://github.com/ziglang/zig/issues/536
             if (gen_info->is_byval && g->zig_target.os != OsWindows) {
                 addLLVMCallsiteAttr(result, (unsigned)gen_info->gen_index, "byval");
             }
    @@ -6730,7 +6730,7 @@ static void init(CodeGen *g) {
         const char *target_specific_features;
         if (g->is_native_target) {
             // LLVM creates invalid binaries on Windows sometimes.
    -        // See https://github.com/zig-lang/zig/issues/508
    +        // See https://github.com/ziglang/zig/issues/508
             // As a workaround we do not use target native features on Windows.
             if (g->zig_target.os == OsWindows) {
                 target_specific_cpu_args = "";
    diff --git a/src/ir.cpp b/src/ir.cpp
    index e2cbba48a7..440063d58d 100644
    --- a/src/ir.cpp
    +++ b/src/ir.cpp
    @@ -12130,7 +12130,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
                 casted_arg->value.type->id == TypeTableEntryIdNumLitFloat)
         {
             ir_add_error(ira, casted_arg,
    -            buf_sprintf("compiler bug: integer and float literals in var args function must be casted. https://github.com/zig-lang/zig/issues/557"));
    +            buf_sprintf("compiler bug: integer and float literals in var args function must be casted. https://github.com/ziglang/zig/issues/557"));
             return false;
         }
     
    @@ -12331,7 +12331,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
     
             if (fn_proto_node->data.fn_proto.is_var_args) {
                 ir_add_error(ira, &call_instruction->base,
    -                    buf_sprintf("compiler bug: unable to call var args function at compile time. https://github.com/zig-lang/zig/issues/313"));
    +                    buf_sprintf("compiler bug: unable to call var args function at compile time. https://github.com/ziglang/zig/issues/313"));
                 return ira->codegen->builtin_types.entry_invalid;
             }
     
    @@ -12424,7 +12424,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
             }
             if (call_instruction->is_async && fn_type_id->is_var_args) {
                 ir_add_error(ira, call_instruction->fn_ref,
    -                buf_sprintf("compiler bug: TODO: implement var args async functions. https://github.com/zig-lang/zig/issues/557"));
    +                buf_sprintf("compiler bug: TODO: implement var args async functions. https://github.com/ziglang/zig/issues/557"));
                 return ira->codegen->builtin_types.entry_invalid;
             }
     
    @@ -12507,7 +12507,7 @@ static TypeTableEntry *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCall *cal
                         VariableTableEntry *arg_var = get_fn_var_by_index(parent_fn_entry, arg_tuple_i);
                         if (arg_var == nullptr) {
                             ir_add_error(ira, arg,
    -                            buf_sprintf("compiler bug: var args can't handle void. https://github.com/zig-lang/zig/issues/557"));
    +                            buf_sprintf("compiler bug: var args can't handle void. https://github.com/ziglang/zig/issues/557"));
                             return ira->codegen->builtin_types.entry_invalid;
                         }
                         IrInstruction *arg_var_ptr_inst = ir_get_var_ptr(ira, arg, arg_var, true, false);
    diff --git a/std/atomic/queue.zig b/std/atomic/queue.zig
    index 288a2b3b48..35180da8d1 100644
    --- a/std/atomic/queue.zig
    +++ b/std/atomic/queue.zig
    @@ -16,7 +16,7 @@ pub fn Queue(comptime T: type) type {
                 data: T,
             };
     
    -        // TODO: well defined copy elision: https://github.com/zig-lang/zig/issues/287
    +        // TODO: well defined copy elision: https://github.com/ziglang/zig/issues/287
             pub fn init(self: &Self) void {
                 self.root.next = null;
                 self.head = &self.root;
    diff --git a/std/event.zig b/std/event.zig
    index b2e7e3ae38..558bd2a188 100644
    --- a/std/event.zig
    +++ b/std/event.zig
    @@ -148,7 +148,7 @@ pub const Loop = struct {
     };
     
     pub async fn connect(loop: &Loop, _address: &const std.net.Address) !std.os.File {
    -    var address = _address.*; // TODO https://github.com/zig-lang/zig/issues/733
    +    var address = _address.*; // TODO https://github.com/ziglang/zig/issues/733
     
         const sockfd = try std.os.posixSocket(posix.AF_INET, posix.SOCK_STREAM | posix.SOCK_CLOEXEC | posix.SOCK_NONBLOCK, posix.PROTO_tcp);
         errdefer std.os.close(sockfd);
    @@ -172,7 +172,7 @@ test "listen on a port, send bytes, receive bytes" {
     
             async<&mem.Allocator> fn handler(tcp_server: &TcpServer, _addr: &const std.net.Address, _socket: &const std.os.File) void {
                 const self = @fieldParentPtr(Self, "tcp_server", tcp_server);
    -            var socket = _socket.*; // TODO https://github.com/zig-lang/zig/issues/733
    +            var socket = _socket.*; // TODO https://github.com/ziglang/zig/issues/733
                 defer socket.close();
                 const next_handler = async errorableHandler(self, _addr, socket) catch |err| switch (err) {
                     error.OutOfMemory => @panic("unable to handle connection: out of memory"),
    @@ -186,8 +186,8 @@ test "listen on a port, send bytes, receive bytes" {
             }
     
             async fn errorableHandler(self: &Self, _addr: &const std.net.Address, _socket: &const std.os.File) !void {
    -            const addr = _addr.*; // TODO https://github.com/zig-lang/zig/issues/733
    -            var socket = _socket.*; // TODO https://github.com/zig-lang/zig/issues/733
    +            const addr = _addr.*; // TODO https://github.com/ziglang/zig/issues/733
    +            var socket = _socket.*; // TODO https://github.com/ziglang/zig/issues/733
     
                 var adapter = std.io.FileOutStream.init(&socket);
                 var stream = &adapter.stream;
    diff --git a/std/fmt/index.zig b/std/fmt/index.zig
    index 0af772b7dc..624751822a 100644
    --- a/std/fmt/index.zig
    +++ b/std/fmt/index.zig
    @@ -824,7 +824,7 @@ test "fmt.format" {
         try testFmt("file size: 63MiB\n", "file size: {Bi}\n", usize(63 * 1024 * 1024));
         try testFmt("file size: 66.06MB\n", "file size: {B2}\n", usize(63 * 1024 * 1024));
         {
    -        // Dummy field because of https://github.com/zig-lang/zig/issues/557.
    +        // Dummy field because of https://github.com/ziglang/zig/issues/557.
             const Struct = struct {
                 unused: u8,
             };
    diff --git a/std/mem.zig b/std/mem.zig
    index 3ca87b35d3..617c1de2f5 100644
    --- a/std/mem.zig
    +++ b/std/mem.zig
    @@ -702,7 +702,7 @@ test "std.mem.rotate" {
         }));
     }
     
    -// TODO: When https://github.com/zig-lang/zig/issues/649 is solved these can be done by
    +// TODO: When https://github.com/ziglang/zig/issues/649 is solved these can be done by
     // endian-casting the pointer and then dereferencing
     
     pub fn endianSwapIfLe(comptime T: type, x: T) T {
    diff --git a/std/os/index.zig b/std/os/index.zig
    index 7d19cd82c6..01e2092e1c 100644
    --- a/std/os/index.zig
    +++ b/std/os/index.zig
    @@ -239,7 +239,7 @@ pub fn close(handle: FileHandle) void {
     /// Calls POSIX read, and keeps trying if it gets interrupted.
     pub fn posixRead(fd: i32, buf: []u8) !void {
         // Linux can return EINVAL when read amount is > 0x7ffff000
    -    // See https://github.com/zig-lang/zig/pull/743#issuecomment-363158274
    +    // See https://github.com/ziglang/zig/pull/743#issuecomment-363158274
         const max_buf_len = 0x7ffff000;
     
         var index: usize = 0;
    @@ -281,7 +281,7 @@ pub const PosixWriteError = error{
     /// Calls POSIX write, and keeps trying if it gets interrupted.
     pub fn posixWrite(fd: i32, bytes: []const u8) !void {
         // Linux can return EINVAL when write amount is > 0x7ffff000
    -    // See https://github.com/zig-lang/zig/pull/743#issuecomment-363165856
    +    // See https://github.com/ziglang/zig/pull/743#issuecomment-363165856
         const max_bytes_len = 0x7ffff000;
     
         var index: usize = 0;
    @@ -2513,7 +2513,7 @@ pub const SpawnThreadError = error{
     /// caller must call wait on the returned thread
     pub fn spawnThread(context: var, comptime startFn: var) SpawnThreadError!&Thread {
         // TODO compile-time call graph analysis to determine stack upper bound
    -    // https://github.com/zig-lang/zig/issues/157
    +    // https://github.com/ziglang/zig/issues/157
         const default_stack_size = 8 * 1024 * 1024;
     
         const Context = @typeOf(context);
    diff --git a/std/os/test.zig b/std/os/test.zig
    index 56d6e8b309..4dfe76224a 100644
    --- a/std/os/test.zig
    +++ b/std/os/test.zig
    @@ -12,7 +12,7 @@ const AtomicOrder = builtin.AtomicOrder;
     test "makePath, put some files in it, deleteTree" {
         if (builtin.os == builtin.Os.windows) {
             // TODO implement os.Dir for windows
    -        // https://github.com/zig-lang/zig/issues/709
    +        // https://github.com/ziglang/zig/issues/709
             return;
         }
         try os.makePath(a, "os_test_tmp/b/c");
    diff --git a/std/os/time.zig b/std/os/time.zig
    index 4fd2c4e924..3af150ab6a 100644
    --- a/std/os/time.zig
    +++ b/std/os/time.zig
    @@ -135,7 +135,7 @@ pub const Timer = struct {
         
         //At some point we may change our minds on RAW, but for now we're
         //  sticking with posix standard MONOTONIC. For more information, see: 
    -    //  https://github.com/zig-lang/zig/pull/933
    +    //  https://github.com/ziglang/zig/pull/933
         //
         //const monotonic_clock_id = switch(builtin.os) {
         //    Os.linux => linux.CLOCK_MONOTONIC_RAW,
    diff --git a/std/special/compiler_rt/comparetf2.zig b/std/special/compiler_rt/comparetf2.zig
    index c189e5803b..760c3689c0 100644
    --- a/std/special/compiler_rt/comparetf2.zig
    +++ b/std/special/compiler_rt/comparetf2.zig
    @@ -1,4 +1,4 @@
    -// TODO https://github.com/zig-lang/zig/issues/305
    +// TODO https://github.com/ziglang/zig/issues/305
     // and then make the return types of some of these functions the enum instead of c_int
     const LE_LESS = c_int(-1);
     const LE_EQUAL = c_int(0);
    @@ -59,7 +59,7 @@ pub extern fn __letf2(a: f128, b: f128) c_int {
         ;
     }
     
    -// TODO https://github.com/zig-lang/zig/issues/305
    +// TODO https://github.com/ziglang/zig/issues/305
     // and then make the return types of some of these functions the enum instead of c_int
     const GE_LESS = c_int(-1);
     const GE_EQUAL = c_int(0);
    diff --git a/std/zig/ast.zig b/std/zig/ast.zig
    index c1552b0220..1f15046a79 100644
    --- a/std/zig/ast.zig
    +++ b/std/zig/ast.zig
    @@ -113,7 +113,7 @@ pub const Error = union(enum) {
     
         pub fn render(self: &Error, tokens: &Tree.TokenList, stream: var) !void {
             switch (self.*) {
    -            // TODO https://github.com/zig-lang/zig/issues/683
    +            // TODO https://github.com/ziglang/zig/issues/683
                 @TagType(Error).InvalidToken => |*x| return x.render(tokens, stream),
                 @TagType(Error).ExpectedVarDeclOrFn => |*x| return x.render(tokens, stream),
                 @TagType(Error).ExpectedAggregateKw => |*x| return x.render(tokens, stream),
    @@ -137,7 +137,7 @@ pub const Error = union(enum) {
     
         pub fn loc(self: &Error) TokenIndex {
             switch (self.*) {
    -            // TODO https://github.com/zig-lang/zig/issues/683
    +            // TODO https://github.com/ziglang/zig/issues/683
                 @TagType(Error).InvalidToken => |x| return x.token,
                 @TagType(Error).ExpectedVarDeclOrFn => |x| return x.token,
                 @TagType(Error).ExpectedAggregateKw => |x| return x.token,
    diff --git a/test/build_examples.zig b/test/build_examples.zig
    index a3b44b9136..7a4c0f35d9 100644
    --- a/test/build_examples.zig
    +++ b/test/build_examples.zig
    @@ -9,7 +9,7 @@ pub fn addCases(cases: &tests.BuildExamplesContext) void {
         cases.add("example/guess_number/main.zig");
         if (!is_windows) {
             // TODO get this test passing on windows
    -        // See https://github.com/zig-lang/zig/issues/538
    +        // See https://github.com/ziglang/zig/issues/538
             cases.addBuildFile("example/shared_library/build.zig");
             cases.addBuildFile("example/mix_o_files/build.zig");
         }
    diff --git a/test/cases/coroutines.zig b/test/cases/coroutines.zig
    index 4aa97861ac..e983947a4c 100644
    --- a/test/cases/coroutines.zig
    +++ b/test/cases/coroutines.zig
    @@ -204,7 +204,7 @@ test "error return trace across suspend points - async return" {
         cancel p2;
     }
     
    -// TODO https://github.com/zig-lang/zig/issues/760
    +// TODO https://github.com/ziglang/zig/issues/760
     fn nonFailing() (promise->error!void) {
         return async suspendThenFail() catch unreachable;
     }
    diff --git a/test/cases/misc.zig b/test/cases/misc.zig
    index 66487a4946..deeeca8c3a 100644
    --- a/test/cases/misc.zig
    +++ b/test/cases/misc.zig
    @@ -543,7 +543,7 @@ test "@typeName" {
         comptime {
             assert(mem.eql(u8, @typeName(i64), "i64"));
             assert(mem.eql(u8, @typeName(&usize), "&usize"));
    -        // https://github.com/zig-lang/zig/issues/675
    +        // https://github.com/ziglang/zig/issues/675
             assert(mem.eql(u8, @typeName(TypeFromFn(u8)), "TypeFromFn(u8)"));
             assert(mem.eql(u8, @typeName(Struct), "Struct"));
             assert(mem.eql(u8, @typeName(Union), "Union"));
    diff --git a/test/compare_output.zig b/test/compare_output.zig
    index b01e87d4eb..905ffd37a9 100644
    --- a/test/compare_output.zig
    +++ b/test/compare_output.zig
    @@ -131,7 +131,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
             \\const is_windows = builtin.os == builtin.Os.windows;
             \\const c = @cImport({
             \\    if (is_windows) {
    -        \\        // See https://github.com/zig-lang/zig/issues/515
    +        \\        // See https://github.com/ziglang/zig/issues/515
             \\        @cDefine("_NO_CRT_STDIO_INLINE", "1");
             \\        @cInclude("io.h");
             \\        @cInclude("fcntl.h");
    @@ -316,7 +316,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) void {
             \\const is_windows = builtin.os == builtin.Os.windows;
             \\const c = @cImport({
             \\    if (is_windows) {
    -        \\        // See https://github.com/zig-lang/zig/issues/515
    +        \\        // See https://github.com/ziglang/zig/issues/515
             \\        @cDefine("_NO_CRT_STDIO_INLINE", "1");
             \\        @cInclude("io.h");
             \\        @cInclude("fcntl.h");
    -- 
    cgit v1.2.3
    
    
    From 1b3aaacba260e4c8d89ac98ab856ff9b3c77dac4 Mon Sep 17 00:00:00 2001
    From: Jimmi HC 
    Date: Wed, 30 May 2018 10:34:20 +0200
    Subject: Removed copy-pasted resolve_inferred_error_set both ir.cpp and
     analyze.cpp have a function resolve_inferred_error_set, which is a nearly
     exact copy-paste. This commit removes the one in ir.cpp and exposes then one
     in analyze.cpp. This also allows us to make analyze_fn_body local to
     analyze.cpp, as it is not used anywhere in ir.cpp after this change
    
    ---
     src/analyze.cpp |  7 ++++---
     src/analyze.hpp |  2 +-
     src/ir.cpp      | 62 +++++++++++++++++++--------------------------------------
     3 files changed, 25 insertions(+), 46 deletions(-)
    
    (limited to 'src/analyze.cpp')
    
    diff --git a/src/analyze.cpp b/src/analyze.cpp
    index c59fde8ef6..b00e18a9a1 100644
    --- a/src/analyze.cpp
    +++ b/src/analyze.cpp
    @@ -25,6 +25,7 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type);
     static void resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type);
     static void resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type);
     static void resolve_union_zero_bits(CodeGen *g, TypeTableEntry *union_type);
    +static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry);
     
     ErrorMsg *add_node_error(CodeGen *g, AstNode *node, Buf *msg) {
         if (node->owner->c_import_node != nullptr) {
    @@ -3880,7 +3881,7 @@ static void define_local_param_variables(CodeGen *g, FnTableEntry *fn_table_entr
         }
     }
     
    -static bool analyze_resolve_inferred_error_set(CodeGen *g, TypeTableEntry *err_set_type, AstNode *source_node) {
    +bool resolve_inferred_error_set(CodeGen *g, TypeTableEntry *err_set_type, AstNode *source_node) {
         FnTableEntry *infer_fn = err_set_type->data.error_set.infer_fn;
         if (infer_fn != nullptr) {
             if (infer_fn->anal_state == FnAnalStateInvalid) {
    @@ -3932,7 +3933,7 @@ void analyze_fn_ir(CodeGen *g, FnTableEntry *fn_table_entry, AstNode *return_typ
                 }
     
                 if (inferred_err_set_type->data.error_set.infer_fn != nullptr) {
    -                if (!analyze_resolve_inferred_error_set(g, inferred_err_set_type, return_type_node)) {
    +                if (!resolve_inferred_error_set(g, inferred_err_set_type, return_type_node)) {
                         fn_table_entry->anal_state = FnAnalStateInvalid;
                         return;
                     }
    @@ -3962,7 +3963,7 @@ void analyze_fn_ir(CodeGen *g, FnTableEntry *fn_table_entry, AstNode *return_typ
         fn_table_entry->anal_state = FnAnalStateComplete;
     }
     
    -void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry) {
    +static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry) {
         assert(fn_table_entry->anal_state != FnAnalStateProbing);
         if (fn_table_entry->anal_state != FnAnalStateReady)
             return;
    diff --git a/src/analyze.hpp b/src/analyze.hpp
    index 56ca21a93f..d538f042ce 100644
    --- a/src/analyze.hpp
    +++ b/src/analyze.hpp
    @@ -191,7 +191,7 @@ void add_fn_export(CodeGen *g, FnTableEntry *fn_table_entry, Buf *symbol_name, G
     
     ConstExprValue *get_builtin_value(CodeGen *codegen, const char *name);
     TypeTableEntry *get_ptr_to_stack_trace_type(CodeGen *g);
    -void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry);
    +bool resolve_inferred_error_set(CodeGen *g, TypeTableEntry *err_set_type, AstNode *source_node);
     
     TypeTableEntry *get_auto_err_set_type(CodeGen *g, FnTableEntry *fn_entry);
     
    diff --git a/src/ir.cpp b/src/ir.cpp
    index 5d182fe9b0..8d32a81e25 100644
    --- a/src/ir.cpp
    +++ b/src/ir.cpp
    @@ -7633,38 +7633,16 @@ static bool slice_is_const(TypeTableEntry *type) {
         return type->data.structure.fields[slice_ptr_index].type_entry->data.pointer.is_const;
     }
     
    -static bool resolve_inferred_error_set(IrAnalyze *ira, TypeTableEntry *err_set_type, AstNode *source_node) {
    -    assert(err_set_type->id == TypeTableEntryIdErrorSet);
    -    FnTableEntry *infer_fn = err_set_type->data.error_set.infer_fn;
    -    if (infer_fn != nullptr) {
    -        if (infer_fn->anal_state == FnAnalStateInvalid) {
    -            return false;
    -        } else if (infer_fn->anal_state == FnAnalStateReady) {
    -            analyze_fn_body(ira->codegen, infer_fn);
    -            if (err_set_type->data.error_set.infer_fn != nullptr) {
    -                assert(ira->codegen->errors.length != 0);
    -                return false;
    -            }
    -        } else {
    -            ir_add_error_node(ira, source_node,
    -                buf_sprintf("cannot resolve inferred error set '%s': function '%s' not fully analyzed yet",
    -                    buf_ptr(&err_set_type->name), buf_ptr(&err_set_type->data.error_set.infer_fn->symbol_name)));
    -            return false;
    -        }
    -    }
    -    return true;
    -}
    -
     static TypeTableEntry *get_error_set_intersection(IrAnalyze *ira, TypeTableEntry *set1, TypeTableEntry *set2,
             AstNode *source_node)
     {
         assert(set1->id == TypeTableEntryIdErrorSet);
         assert(set2->id == TypeTableEntryIdErrorSet);
     
    -    if (!resolve_inferred_error_set(ira, set1, source_node)) {
    +    if (!resolve_inferred_error_set(ira->codegen, set1, source_node)) {
             return ira->codegen->builtin_types.entry_invalid;
         }
    -    if (!resolve_inferred_error_set(ira, set2, source_node)) {
    +    if (!resolve_inferred_error_set(ira->codegen, set2, source_node)) {
             return ira->codegen->builtin_types.entry_invalid;
         }
         if (type_is_global_error_set(set1)) {
    @@ -7803,7 +7781,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, TypeTableEntry
                 return result;
             }
     
    -        if (!resolve_inferred_error_set(ira, contained_set, source_node)) {
    +        if (!resolve_inferred_error_set(ira->codegen, contained_set, source_node)) {
                 result.id = ConstCastResultIdUnresolvedInferredErrSet;
                 return result;
             }
    @@ -8192,7 +8170,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
                 err_set_type = ira->codegen->builtin_types.entry_global_error_set;
             } else {
                 err_set_type = prev_inst->value.type;
    -            if (!resolve_inferred_error_set(ira, err_set_type, prev_inst->source_node)) {
    +            if (!resolve_inferred_error_set(ira->codegen, err_set_type, prev_inst->source_node)) {
                     return ira->codegen->builtin_types.entry_invalid;
                 }
                 update_errors_helper(ira->codegen, &errors, &errors_count);
    @@ -8231,7 +8209,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
                     if (type_is_global_error_set(err_set_type)) {
                         continue;
                     }
    -                if (!resolve_inferred_error_set(ira, cur_type, cur_inst->source_node)) {
    +                if (!resolve_inferred_error_set(ira->codegen, cur_type, cur_inst->source_node)) {
                         return ira->codegen->builtin_types.entry_invalid;
                     }
                     if (type_is_global_error_set(cur_type)) {
    @@ -8297,7 +8275,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
                         continue;
                     }
                     TypeTableEntry *cur_err_set_type = cur_type->data.error_union.err_set_type;
    -                if (!resolve_inferred_error_set(ira, cur_err_set_type, cur_inst->source_node)) {
    +                if (!resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->source_node)) {
                         return ira->codegen->builtin_types.entry_invalid;
                     }
                     if (type_is_global_error_set(cur_err_set_type)) {
    @@ -8360,7 +8338,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
                 if (err_set_type != nullptr && type_is_global_error_set(err_set_type)) {
                     continue;
                 }
    -            if (!resolve_inferred_error_set(ira, cur_type, cur_inst->source_node)) {
    +            if (!resolve_inferred_error_set(ira->codegen, cur_type, cur_inst->source_node)) {
                     return ira->codegen->builtin_types.entry_invalid;
                 }
     
    @@ -8417,11 +8395,11 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
                     TypeTableEntry *prev_err_set_type = (err_set_type == nullptr) ? prev_type->data.error_union.err_set_type : err_set_type;
                     TypeTableEntry *cur_err_set_type = cur_type->data.error_union.err_set_type;
     
    -                if (!resolve_inferred_error_set(ira, prev_err_set_type, cur_inst->source_node)) {
    +                if (!resolve_inferred_error_set(ira->codegen, prev_err_set_type, cur_inst->source_node)) {
                         return ira->codegen->builtin_types.entry_invalid;
                     }
     
    -                if (!resolve_inferred_error_set(ira, cur_err_set_type, cur_inst->source_node)) {
    +                if (!resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->source_node)) {
                         return ira->codegen->builtin_types.entry_invalid;
                     }
     
    @@ -8531,7 +8509,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
             {
                 if (err_set_type != nullptr) {
                     TypeTableEntry *cur_err_set_type = cur_type->data.error_union.err_set_type;
    -                if (!resolve_inferred_error_set(ira, cur_err_set_type, cur_inst->source_node)) {
    +                if (!resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->source_node)) {
                         return ira->codegen->builtin_types.entry_invalid;
                     }
                     if (type_is_global_error_set(cur_err_set_type) || type_is_global_error_set(err_set_type)) {
    @@ -9213,7 +9191,7 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou
             if (!val)
                 return ira->codegen->invalid_instruction;
     
    -        if (!resolve_inferred_error_set(ira, wanted_type, source_instr->source_node)) {
    +        if (!resolve_inferred_error_set(ira->codegen, wanted_type, source_instr->source_node)) {
                 return ira->codegen->invalid_instruction;
             }
             if (!type_is_global_error_set(wanted_type)) {
    @@ -9654,7 +9632,7 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc
             IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,
                     source_instr->source_node, wanted_type);
     
    -        if (!resolve_inferred_error_set(ira, wanted_type, source_instr->source_node)) {
    +        if (!resolve_inferred_error_set(ira->codegen, wanted_type, source_instr->source_node)) {
                 return ira->codegen->invalid_instruction;
             }
     
    @@ -9752,7 +9730,7 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc
             zig_unreachable();
         }
         if (!type_is_global_error_set(err_set_type)) {
    -        if (!resolve_inferred_error_set(ira, err_set_type, source_instr->source_node)) {
    +        if (!resolve_inferred_error_set(ira->codegen, err_set_type, source_instr->source_node)) {
                 return ira->codegen->invalid_instruction;
             }
             if (err_set_type->data.error_set.err_count == 0) {
    @@ -10647,7 +10625,7 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
                 return ira->codegen->builtin_types.entry_invalid;
             }
     
    -        if (!resolve_inferred_error_set(ira, intersect_type, source_node)) {
    +        if (!resolve_inferred_error_set(ira->codegen, intersect_type, source_node)) {
                 return ira->codegen->builtin_types.entry_invalid;
             }
     
    @@ -11503,11 +11481,11 @@ static TypeTableEntry *ir_analyze_merge_error_sets(IrAnalyze *ira, IrInstruction
             return ira->codegen->builtin_types.entry_type;
         }
     
    -    if (!resolve_inferred_error_set(ira, op1_type, instruction->op1->other->source_node)) {
    +    if (!resolve_inferred_error_set(ira->codegen, op1_type, instruction->op1->other->source_node)) {
             return ira->codegen->builtin_types.entry_invalid;
         }
     
    -    if (!resolve_inferred_error_set(ira, op2_type, instruction->op2->other->source_node)) {
    +    if (!resolve_inferred_error_set(ira->codegen, op2_type, instruction->op2->other->source_node)) {
             return ira->codegen->builtin_types.entry_invalid;
         }
     
    @@ -13851,7 +13829,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
                     }
                     err_set_type = err_entry->set_with_only_this_in_it;
                 } else {
    -                if (!resolve_inferred_error_set(ira, child_type, field_ptr_instruction->base.source_node)) {
    +                if (!resolve_inferred_error_set(ira->codegen, child_type, field_ptr_instruction->base.source_node)) {
                         return ira->codegen->builtin_types.entry_invalid;
                     }
                     err_entry = find_err_table_entry(child_type, field_name);
    @@ -17559,7 +17537,7 @@ static TypeTableEntry *ir_analyze_instruction_member_count(IrAnalyze *ira, IrIns
         } else if (container_type->id == TypeTableEntryIdUnion) {
             result = container_type->data.unionation.src_field_count;
         } else if (container_type->id == TypeTableEntryIdErrorSet) {
    -        if (!resolve_inferred_error_set(ira, container_type, instruction->base.source_node)) {
    +        if (!resolve_inferred_error_set(ira->codegen, container_type, instruction->base.source_node)) {
                 return ira->codegen->builtin_types.entry_invalid;
             }
             if (type_is_global_error_set(container_type)) {
    @@ -17863,7 +17841,7 @@ static TypeTableEntry *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstruc
             }
     
             TypeTableEntry *err_set_type = type_entry->data.error_union.err_set_type;
    -        if (!resolve_inferred_error_set(ira, err_set_type, instruction->base.source_node)) {
    +        if (!resolve_inferred_error_set(ira->codegen, err_set_type, instruction->base.source_node)) {
                 return ira->codegen->builtin_types.entry_invalid;
             }
             if (!type_is_global_error_set(err_set_type) &&
    @@ -18131,7 +18109,7 @@ static TypeTableEntry *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira
                 }
             }
         } else if (switch_type->id == TypeTableEntryIdErrorSet) {
    -        if (!resolve_inferred_error_set(ira, switch_type, target_value->source_node)) {
    +        if (!resolve_inferred_error_set(ira->codegen, switch_type, target_value->source_node)) {
                 return ira->codegen->builtin_types.entry_invalid;
             }
     
    -- 
    cgit v1.2.3