hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 3325561cd0358974dea87cc0b00065603688392b
parent d83ff036f3bd97571c928f868c6960c4cc9ade3c
Author: Drew DeVault <sir@cmpwn.com>
Date:   Tue, 20 Apr 2021 08:44:47 -0400

hare::unparse: fix test issues

Diffstat:
Mhare/unparse/decl.ha | 15++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/hare/unparse/decl.ha b/hare/unparse/decl.ha @@ -21,8 +21,13 @@ export fn decl(out: *io::stream, d: ast::decl) (size | io::error) = { n += ident(out, g[i].ident)?; n += fmt::fprint(out, ": ")?; n += _type(out, 0, g[i]._type)?; - n += fmt::fprint(out, " = ")?; - n += expr(out, 0, g[i].init)?; + match (g[i].init) { + null => void, + ex: *ast::expr => { + n += fmt::fprint(out, " = ")?; + n += expr(out, 0, *ex)?; + }, + }; if (i + 1 < len(g)) { n += fmt::fprint(out, ", ")?; }; @@ -122,14 +127,14 @@ fn decl_test(d: ast::decl, expected: str) bool = { symbol = "", ident = ["foo", "bar"], _type = type_int, - init = expr_void, + init = alloc(expr_void), }, ast::decl_global { is_const = false, symbol = "foobar", ident = ["baz"], _type = type_int, - init = expr_void, + init = alloc(expr_void), }, ], }; @@ -141,7 +146,7 @@ fn decl_test(d: ast::decl, expected: str) bool = { is_const = true, ident = ["foo"], _type = type_int, - init = expr_void, + init = alloc(expr_void), ... }, ];