| author | |
| committer | |
| log | 30c9808391bead620eaf24991d7a9ba21e4266b9 |
| tree | be1503cdce50bcdd35a993e1e4b46f04572bb05c |
| parent | a62db38d905ad4962c3b37e013c8745ed6ecbfb9 |
3 files changed, 20 insertions(+), 12 deletions(-)
lib/std/zig/ast.zig+7-6| ... | ... | @@ -2172,6 +2172,10 @@ pub const full = struct { |
| 2172 | 2172 | }; |
| 2173 | 2173 | it.param_i += 1; |
| 2174 | 2174 | it.tok_i = it.tree.lastToken(param_type) + 1; |
| 2175 | // Look for anytype and ... params afterwards. | |
| 2176 | if (token_tags[it.tok_i] == .comma) { | |
| 2177 | it.tok_i += 1; | |
| 2178 | } | |
| 2175 | 2179 | it.tok_flag = true; |
| 2176 | 2180 | return Param{ |
| 2177 | 2181 | .first_doc_comment = first_doc_comment, |
| ... | ... | @@ -2181,10 +2185,7 @@ pub const full = struct { |
| 2181 | 2185 | .type_expr = param_type, |
| 2182 | 2186 | }; |
| 2183 | 2187 | } |
| 2184 | // Look for anytype and ... params afterwards. | |
| 2185 | if (token_tags[it.tok_i] == .comma) { | |
| 2186 | it.tok_i += 1; | |
| 2187 | } else { | |
| 2188 | if (token_tags[it.tok_i] == .r_paren) { | |
| 2188 | 2189 | return null; |
| 2189 | 2190 | } |
| 2190 | 2191 | if (token_tags[it.tok_i] == .doc_comment) { |
| ... | ... | @@ -2236,8 +2237,8 @@ pub const full = struct { |
| 2236 | 2237 | .tree = &tree, |
| 2237 | 2238 | .fn_proto = &fn_proto, |
| 2238 | 2239 | .param_i = 0, |
| 2239 | .tok_i = undefined, | |
| 2240 | .tok_flag = false, | |
| 2240 | .tok_i = fn_proto.lparen + 1, | |
| 2241 | .tok_flag = true, | |
| 2241 | 2242 | }; |
| 2242 | 2243 | } |
| 2243 | 2244 | }; |
src/AstGen.zig+9-6| ... | ... | @@ -2334,7 +2334,11 @@ fn fnDecl( |
| 2334 | 2334 | var count: usize = 0; |
| 2335 | 2335 | var it = fn_proto.iterate(tree.*); |
| 2336 | 2336 | while (it.next()) |param| { |
| 2337 | if (param.anytype_ellipsis3) |some| if (token_tags[some] == .ellipsis3) break; | |
| 2337 | if (param.anytype_ellipsis3) |token| switch (token_tags[token]) { | |
| 2338 | .ellipsis3 => break, | |
| 2339 | .keyword_anytype => {}, | |
| 2340 | else => unreachable, | |
| 2341 | }; | |
| 2338 | 2342 | count += 1; |
| 2339 | 2343 | } |
| 2340 | 2344 | break :blk count; |
| ... | ... | @@ -2358,11 +2362,10 @@ fn fnDecl( |
| 2358 | 2362 | while (it.next()) |param| : (param_type_i += 1) { |
| 2359 | 2363 | if (param.anytype_ellipsis3) |token| { |
| 2360 | 2364 | switch (token_tags[token]) { |
| 2361 | .keyword_anytype => return astgen.failTok( | |
| 2362 | token, | |
| 2363 | "TODO implement anytype parameter", | |
| 2364 | .{}, | |
| 2365 | ), | |
| 2365 | .keyword_anytype => { | |
| 2366 | param_types[param_type_i] = .none; | |
| 2367 | continue; | |
| 2368 | }, | |
| 2366 | 2369 | .ellipsis3 => { |
| 2367 | 2370 | is_var_args = true; |
| 2368 | 2371 | break; |
src/Zir.zig+4| ... | ... | @@ -1816,6 +1816,7 @@ pub const Inst = struct { |
| 1816 | 1816 | |
| 1817 | 1817 | /// Trailing: |
| 1818 | 1818 | /// 0. param_type: Ref // for each param_types_len |
| 1819 | /// - `none` indicates that the param type is `anytype`. | |
| 1819 | 1820 | /// 1. body: Index // for each body_len |
| 1820 | 1821 | pub const Func = struct { |
| 1821 | 1822 | return_type: Ref, |
| ... | ... | @@ -3304,7 +3305,10 @@ const Writer = struct { |
| 3304 | 3305 | |
| 3305 | 3306 | try stream.writeAll(", {\n"); |
| 3306 | 3307 | self.indent += 2; |
| 3308 | const prev_param_count = self.param_count; | |
| 3309 | self.param_count = param_types.len; | |
| 3307 | 3310 | try self.writeBody(stream, body); |
| 3311 | self.param_count = prev_param_count; | |
| 3308 | 3312 | self.indent -= 2; |
| 3309 | 3313 | try stream.writeByteNTimes(' ', self.indent); |
| 3310 | 3314 | try stream.writeAll("}) "); |