From d8560edc2941016a12a03df36035cabd537dde77 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 19 Feb 2021 20:28:47 -0700 Subject: [PATCH] stage2: fix incorrect ast.Tree.getNodeSource impl --- lib/std/zig/ast.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/std/zig/ast.zig b/lib/std/zig/ast.zig index fda2916af4..943ddd30db 100644 --- a/lib/std/zig/ast.zig +++ b/lib/std/zig/ast.zig @@ -1071,8 +1071,8 @@ pub const Tree = struct { const first_token = tree.firstToken(node); const last_token = tree.lastToken(node); const start = token_starts[first_token]; - const len = tree.tokenSlice(last_token).len; - return tree.source[start..][0..len]; + const end = token_starts[last_token] + tree.tokenSlice(last_token).len; + return tree.source[start..end]; } pub fn globalVarDecl(tree: Tree, node: Node.Index) full.VarDecl {