From 4923048d9556868c7ac4377a353c4e1618142c04 Mon Sep 17 00:00:00 2001 From: zakuro Date: Wed, 13 Jan 2021 22:54:41 +0900 Subject: [PATCH] ast: add case for ConstDecl in `fn (node Stmt) str()` (#8073) --- vlib/v/ast/str.v | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vlib/v/ast/str.v b/vlib/v/ast/str.v index e49f0d69fe..005880bb30 100644 --- a/vlib/v/ast/str.v +++ b/vlib/v/ast/str.v @@ -338,6 +338,12 @@ pub fn (node Stmt) str() string { BranchStmt { return node.str() } + ConstDecl { + fields := node.fields.map(fn (f ConstField) string { + return '${f.name.trim_prefix(f.mod + '.')} = $f.expr' + }) + return 'const (${fields.join(' ')})' + } ExprStmt { return node.expr.str() }