authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-05-24 10:03:08-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-05-24 10:03:26-04:00
log1c0b7ddda8bfabc9274f0d3bcb79be8eb8869f36
treebbeb746c148efb2382fe2042604c072a3fec0060
parent2ff3995a708b03480d5ca51b3ffa92f52cdf81d0

fix regression in AST node iteration

the new iteration code caused an integer underflow for function prototypes with no parameters. now fixed.

1 files changed, 3 insertions(+), 3 deletions(-)

lib/std/zig/ast.zig+3-3
...@@ -706,7 +706,6 @@ pub const Node = struct {...@@ -706,7 +706,6 @@ pub const Node = struct {
706 return null;706 return null;
707 }707 }
708708
709
710 pub fn firstToken(self: *const VarDecl) TokenIndex {709 pub fn firstToken(self: *const VarDecl) TokenIndex {
711 if (self.visib_token) |visib_token| return visib_token;710 if (self.visib_token) |visib_token| return visib_token;
712 if (self.thread_local_token) |thread_local_token| return thread_local_token;711 if (self.thread_local_token) |thread_local_token| return thread_local_token;
...@@ -1049,7 +1048,9 @@ pub const Node = struct {...@@ -1049,7 +1048,9 @@ pub const Node = struct {
1049 i -= 1;1048 i -= 1;
1050 }1049 }
10511050
1052 const params_len = switch (self.paramsConst()[self.params_len - 1].param_type) {1051 const params_len: usize = if (self.params_len == 0)
1052 0
1053 else switch (self.paramsConst()[self.params_len - 1].param_type) {
1053 .var_type, .type_expr => self.params_len,1054 .var_type, .type_expr => self.params_len,
1054 .var_args => self.params_len - 1,1055 .var_args => self.params_len - 1,
1055 };1056 };
...@@ -2660,7 +2661,6 @@ pub const Node = struct {...@@ -2660,7 +2661,6 @@ pub const Node = struct {
2660 }2661 }
2661 };2662 };
26622663
2663
2664 pub fn iterate(self: *const Asm, index: usize) ?*Node {2664 pub fn iterate(self: *const Asm, index: usize) ?*Node {
2665 var i = index;2665 var i = index;
26662666