Commit bf46117f13

xackus <14938807+xackus@users.noreply.github.com>
2020-04-07 22:55:52
std lib docs: fix null and int values
1 parent ed23dad
Changed files (2)
lib
std
special
docs
src
lib/std/special/docs/main.js
@@ -542,8 +542,20 @@
                 } else {
                     return value + "";
                 }
+            case typeKinds.Optional:
+                if(value === 'null'){
+                    if (wantHtml) {
+                        return '<span class="tok-null">' + value + '</span>';
+                    } 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";
         }
     }
 
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;