Commit d8560edc29

Andrew Kelley <andrew@ziglang.org>
2021-02-20 04:28:47
stage2: fix incorrect ast.Tree.getNodeSource impl
1 parent 70761d7
Changed files (1)
lib
std
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 {