| author | |
| committer | |
| log | 9024f27d8f5cb651e2260348ce0ee6fd67fc2c32 |
| tree | a81a64a9c8656dd4f68e4058ce8695b228d20e1b |
| parent | 3568cd4b8f52164d8a519576cc9ea95bb303cd92 |
| parent | c8a066f408a5f6b5aa75359a4a5cb3731677d2ef |
| signature |
stage2: fix extern fn decl parsing and astgen3 files changed, 11 insertions(+), 1 deletions(-)
lib/std/zig/Ast.zig+4| ... | ... | @@ -262,6 +262,9 @@ pub fn renderError(tree: Tree, parse_error: Error, stream: anytype) !void { |
| 262 | 262 | token_tags[parse_error.token].symbol(), |
| 263 | 263 | }); |
| 264 | 264 | }, |
| 265 | .extern_fn_body => { | |
| 266 | return stream.writeAll("extern functions have no body"); | |
| 267 | }, | |
| 265 | 268 | .extra_addrspace_qualifier => { |
| 266 | 269 | return stream.writeAll("extra addrspace qualifier"); |
| 267 | 270 | }, |
| ... | ... | @@ -2447,6 +2450,7 @@ pub const Error = struct { |
| 2447 | 2450 | expected_var_decl_or_fn, |
| 2448 | 2451 | expected_loop_payload, |
| 2449 | 2452 | expected_container, |
| 2453 | extern_fn_body, | |
| 2450 | 2454 | extra_addrspace_qualifier, |
| 2451 | 2455 | extra_align_qualifier, |
| 2452 | 2456 | extra_allowzero_qualifier, |
lib/std/zig/parse.zig+6| ... | ... | @@ -532,11 +532,13 @@ const Parser = struct { |
| 532 | 532 | /// / KEYWORD_usingnamespace Expr SEMICOLON |
| 533 | 533 | fn expectTopLevelDecl(p: *Parser) !Node.Index { |
| 534 | 534 | const extern_export_inline_token = p.nextToken(); |
| 535 | var is_extern: bool = false; | |
| 535 | 536 | var expect_fn: bool = false; |
| 536 | 537 | var expect_var_or_fn: bool = false; |
| 537 | 538 | switch (p.token_tags[extern_export_inline_token]) { |
| 538 | 539 | .keyword_extern => { |
| 539 | 540 | _ = p.eatToken(.string_literal); |
| 541 | is_extern = true; | |
| 540 | 542 | expect_var_or_fn = true; |
| 541 | 543 | }, |
| 542 | 544 | .keyword_export => expect_var_or_fn = true, |
| ... | ... | @@ -554,6 +556,10 @@ const Parser = struct { |
| 554 | 556 | const fn_decl_index = try p.reserveNode(); |
| 555 | 557 | const body_block = try p.parseBlock(); |
| 556 | 558 | assert(body_block != 0); |
| 559 | if (is_extern) { | |
| 560 | try p.warnMsg(.{ .tag = .extern_fn_body, .token = extern_export_inline_token }); | |
| 561 | return null_node; | |
| 562 | } | |
| 557 | 563 | return p.setNode(fn_decl_index, .{ |
| 558 | 564 | .tag = .fn_decl, |
| 559 | 565 | .main_token = p.nodes.items(.main_token)[fn_proto], |
src/AstGen.zig+1-1| ... | ... | @@ -3147,7 +3147,7 @@ fn fnDecl( |
| 3147 | 3147 | break :param indexToRef(param_inst); |
| 3148 | 3148 | }; |
| 3149 | 3149 | |
| 3150 | if (param_name == 0) continue; | |
| 3150 | if (param_name == 0 or is_extern) continue; | |
| 3151 | 3151 | |
| 3152 | 3152 | const sub_scope = try astgen.arena.create(Scope.LocalVal); |
| 3153 | 3153 | sub_scope.* = .{ |