diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-06-10 01:13:51 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-10 01:13:51 -0400 |
| commit | 77678b2cbc7ac9ba2d5d4725241f6a9f7ac64fa4 (patch) | |
| tree | 207f75d690aa32ba054c0a4a78ad05ad1ca9902e /src/ast_render.cpp | |
| parent | ec1b6f66737f8c3cbc0420715c2c502c7e710081 (diff) | |
| download | zig-77678b2cbc7ac9ba2d5d4725241f6a9f7ac64fa4.tar.gz zig-77678b2cbc7ac9ba2d5d4725241f6a9f7ac64fa4.zip | |
breaking syntax change: orelse keyword instead of ?? (#1096)
use the `zig-fmt-optional-default` branch to have zig fmt
automatically do the changes.
closes #1023
Diffstat (limited to 'src/ast_render.cpp')
| -rw-r--r-- | src/ast_render.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/ast_render.cpp b/src/ast_render.cpp index 2c8c03b226..2ace00885d 100644 --- a/src/ast_render.cpp +++ b/src/ast_render.cpp @@ -50,7 +50,7 @@ static const char *bin_op_str(BinOpType bin_op) { case BinOpTypeAssignBitXor: return "^="; case BinOpTypeAssignBitOr: return "|="; case BinOpTypeAssignMergeErrorSets: return "||="; - case BinOpTypeUnwrapOptional: return "??"; + case BinOpTypeUnwrapOptional: return "orelse"; case BinOpTypeArrayCat: return "++"; case BinOpTypeArrayMult: return "**"; case BinOpTypeErrorUnion: return "!"; @@ -67,7 +67,6 @@ static const char *prefix_op_str(PrefixOp prefix_op) { case PrefixOpBoolNot: return "!"; case PrefixOpBinNot: return "~"; case PrefixOpOptional: return "?"; - case PrefixOpUnwrapOptional: return "??"; case PrefixOpAddrOf: return "&"; } zig_unreachable(); @@ -222,6 +221,8 @@ static const char *node_type_str(NodeType node_type) { return "FieldAccessExpr"; case NodeTypePtrDeref: return "PtrDerefExpr"; + case NodeTypeUnwrapOptional: + return "UnwrapOptional"; case NodeTypeContainerDecl: return "ContainerDecl"; case NodeTypeStructField: @@ -711,6 +712,13 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { fprintf(ar->f, ".*"); break; } + case NodeTypeUnwrapOptional: + { + AstNode *lhs = node->data.unwrap_optional.expr; + render_node_ungrouped(ar, lhs); + fprintf(ar->f, ".?"); + break; + } case NodeTypeUndefinedLiteral: fprintf(ar->f, "undefined"); break; |
