Fixed underflow in edgecase in getDocCommentTokenIndex

This commit is contained in:
Alexandros Naskos 2021-04-04 02:12:57 +03:00
parent 406214fb43
commit 04372999aa
No known key found for this signature in database
GPG Key ID: 02BF2E72B0EA32D2

View File

@ -41,11 +41,10 @@ pub fn getDocCommentTokenIndex(tokens: []std.zig.Token.Tag, base_token: ast.Toke
// Find first doc comment token // Find first doc comment token
if (!(tokens[idx] == .doc_comment or tokens[idx] == .container_doc_comment)) if (!(tokens[idx] == .doc_comment or tokens[idx] == .container_doc_comment))
return null; return null;
while (tokens[idx] == .doc_comment or tokens[idx] == .container_doc_comment) { return while (tokens[idx] == .doc_comment or tokens[idx] == .container_doc_comment) {
if (idx == 0) break 0;
idx -= 1; idx -= 1;
if (idx < 0) break; } else idx + 1;
}
return idx + 1;
} }
pub fn collectDocComments( pub fn collectDocComments(
@ -2728,12 +2727,6 @@ fn makeScopeInternal(
param.type_expr, param.type_expr,
); );
} }
const a = data[node_idx];
const left = data[a.lhs];
const right = data[a.rhs];
// log.debug("Alive 3.2 - {}- {}- {}-{} {}- {}-{}", .{tags[node_idx], tags[a.lhs], tags[left.lhs], tags[left.rhs], tags[a.rhs], tags[right.lhs], tags[right.rhs]});
// TODO: This should be the proto
if (fn_tag == .fn_decl) blk: { if (fn_tag == .fn_decl) blk: {
if (data[node_idx].lhs == 0) break :blk; if (data[node_idx].lhs == 0) break :blk;