From bf46117f1314653df3a70ede05aabcd599ce6b08 Mon Sep 17 00:00:00 2001 From: xackus <14938807+xackus@users.noreply.github.com> Date: Tue, 7 Apr 2020 22:55:52 +0200 Subject: [PATCH] std lib docs: fix null and int values --- lib/std/special/docs/main.js | 12 ++++++++++++ src/dump_analysis.cpp | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/lib/std/special/docs/main.js b/lib/std/special/docs/main.js index b11e10caa7..9ec0b65c9b 100644 --- a/lib/std/special/docs/main.js +++ b/lib/std/special/docs/main.js @@ -542,8 +542,20 @@ } else { return value + ""; } + case typeKinds.Optional: + if(value === 'null'){ + if (wantHtml) { + return '' + value + ''; + } else { + return value + ""; + } + } else { + console.trace("TODO non-null optional value printing"); + return "TODO"; + } default: console.trace("TODO implement getValueText for this type:", zigAnalysis.typeKinds[typeObj.kind]); + return "TODO"; } } diff --git a/src/dump_analysis.cpp b/src/dump_analysis.cpp index 3522dcf6f4..31a0f31bdf 100644 --- a/src/dump_analysis.cpp +++ b/src/dump_analysis.cpp @@ -693,6 +693,18 @@ static void anal_dump_value(AnalDumpCtx *ctx, AstNode *source_node, ZigType *ty, } return; } + case ZigTypeIdOptional: { + if(optional_value_is_null(value)){ + jw_string(&ctx->jw, "null"); + } else { + jw_null(&ctx->jw); + } + return; + } + case ZigTypeIdInt: { + jw_bigint(&ctx->jw, &value->data.x_bigint); + return; + } default: jw_null(&ctx->jw); return;