hare

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

commit ef5d8c7ed0ecf79ee95b51383a5b2cb42b601081
parent 21273579b095bfb01d6438a3f47f8526554e7da6
Author: Alexey Yerin <yyp@disroot.org>
Date:   Fri, 27 Aug 2021 22:06:21 +0300

hare::unparse: move '!' to the beginning

Error flag was moved to beginning of the type in hare::parse but without
corresponding unparse changes. Also fixes haredoc's prototype output.

Signed-off-by: Alexey Yerin <yyp@disroot.org>

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

diff --git a/hare/unparse/type.ha b/hare/unparse/type.ha @@ -114,6 +114,9 @@ export fn _type( && !(t.repr is ast::func_type)) { n += fmt::fprint(out, "const ")?; }; + if (t.flags & ast::type_flags::ERROR != 0) { + n += fmt::fprint(out, "!")?; + }; match (t.repr) { a: ast::alias_type => { if (a.unwrap) { @@ -195,9 +198,6 @@ export fn _type( n += fmt::fprint(out, ")")?; }, }; - if (t.flags & ast::type_flags::ERROR != 0) { - n += fmt::fprint(out, "!")?; - }; return n; }; @@ -246,7 +246,7 @@ fn type_test(t: ast::_type, expected: str) bool = { t.flags = ast::type_flags::ERROR; t.repr = ast::builtin_type::INT; - assert(type_test(t, "int!")); + assert(type_test(t, "!int")); t.flags = ast::type_flags::CONST | ast::type_flags::ERROR; t.repr = ast::enum_type { @@ -262,7 +262,7 @@ fn type_test(t: ast::_type, expected: str) bool = { }, ], }; - assert(type_test(t, "const enum u32 {\n\tFOO,\n\tBAR = void,\n}!")); + assert(type_test(t, "const !enum u32 {\n\tFOO,\n\tBAR = void,\n}")); t.flags = 0;