authorgravatar for ashe@kivikakk.eeAsherah Connor <ashe@kivikakk.ee> 2021-02-04 21:33:41+11:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-02-04 10:49:45-08:00
log4428acf0f7b4b8da2709bffe1c304df435d89eed
tree18f047fac71aab880a06437f8de5a4f7da6981c8
parent725adf833289e0a1b0826c6a774cea5283cec744

zig fmt: deref, unwrap optional


3 files changed, 19 insertions(+), 24 deletions(-)

lib/std/zig/ast.zig+1-1
......@@ -462,6 +462,7 @@ pub const Tree = struct {
462462 .UndefinedLiteral,
463463 .UnreachableLiteral,
464464 .Identifier,
465 .Deref,
465466 => return main_tokens[n] + end_offset,
466467
467468 .Call,
......@@ -515,7 +516,6 @@ pub const Tree = struct {
515516 .Asm => unreachable, // TODO
516517 .SliceOpen => unreachable, // TODO
517518 .Slice => unreachable, // TODO
518 .Deref => unreachable, // TODO
519519 .ArrayInitOne => unreachable, // TODO
520520 .ArrayInit => unreachable, // TODO
521521 .StructInitOne => unreachable, // TODO
lib/std/zig/parser_test.zig+9-9
......@@ -1503,15 +1503,15 @@ test "zig fmt: top-level fields" {
15031503// \\
15041504// );
15051505//}
1506//
1507//test "zig fmt: ptr deref operator and unwrap optional operator" {
1508// try testCanonical(
1509// \\const a = b.*;
1510// \\const a = b.?;
1511// \\
1512// );
1513//}
1514//
1506
1507test "zig fmt: ptr deref operator and unwrap optional operator" {
1508 try testCanonical(
1509 \\const a = b.*;
1510 \\const a = b.?;
1511 \\
1512 );
1513}
1514
15151515//test "zig fmt: comment after if before another if" {
15161516// try testCanonical(
15171517// \\test "aoeu" {
lib/std/zig/render.zig+9-14
......@@ -991,21 +991,16 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac
991991 // return renderToken(ais, tree, suffix_op.rtoken, space); // ]
992992 //},
993993
994 .Deref => unreachable, // TODO
995 //.Deref => {
996 // const suffix_op = base.castTag(.Deref).?;
997
998 // try renderExpression(ais, tree, suffix_op.lhs, Space.None);
999 // return renderToken(ais, tree, suffix_op.rtoken, space); // .*
1000 //},
1001 .UnwrapOptional => unreachable, // TODO
1002 //.UnwrapOptional => {
1003 // const suffix_op = base.castTag(.UnwrapOptional).?;
994 .Deref => {
995 try renderExpression(ais, tree, datas[node].lhs, .None);
996 return renderToken(ais, tree, main_tokens[node], space);
997 },
1004998
1005 // try renderExpression(ais, tree, suffix_op.lhs, Space.None);
1006 // try renderToken(ais, tree, tree.prevToken(suffix_op.rtoken), Space.None); // .
1007 // return renderToken(ais, tree, suffix_op.rtoken, space); // ?
1008 //},
999 .UnwrapOptional => {
1000 try renderExpression(ais, tree, datas[node].lhs, .None);
1001 try renderToken(ais, tree, main_tokens[node], .None);
1002 return renderToken(ais, tree, datas[node].rhs, space);
1003 },
10091004
10101005 .Break => unreachable, // TODO
10111006 //.Break => {