hare

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

commit c62d8beee782b52b9cee79379fe55a284d22f719
parent f02b0ddb556f7b516be8184dbe013519113a4b0b
Author: Sebastian <sebastian@sebsite.pw>
Date:   Fri, 13 May 2022 22:44:19 -0400

haredoc: handle module::error

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mcmd/haredoc/errors.ha | 5++++-
Mcmd/haredoc/hare.ha | 12+++++++++---
2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/cmd/haredoc/errors.ha b/cmd/haredoc/errors.ha @@ -2,10 +2,11 @@ // (c) 2021 Drew DeVault <sir@cmpwn.com> // (c) 2021 Eyal Sawady <ecs@d2evs.net> use hare::lex; +use hare::module; use hare::parse; use io; -type error = !(lex::error | parse::error | io::error); +type error = !(lex::error | parse::error | io::error | module::error); fn strerror(err: error) str = { match (err) { @@ -15,5 +16,7 @@ fn strerror(err: error) str = { return parse::strerror(err); case let err: io::error => return io::strerror(err); + case let err: module::error => + return module::strerror(err); }; }; diff --git a/cmd/haredoc/hare.ha b/cmd/haredoc/hare.ha @@ -78,7 +78,7 @@ fn emit_submodules(ctx: *context) (void | error) = { defer free(identpath); let submodules: []str = []; - defer free(submodules); + defer strings::freeall(submodules); for (let i = 0z; i < len(ctx.version.subdirs); i += 1) { let dir = ctx.version.subdirs[i]; @@ -92,8 +92,14 @@ fn emit_submodules(ctx: *context) (void | error) = { if (dir == "scripts") continue; let submod = [identpath, dir]: ast::ident; - if (module::lookup(ctx.mctx, submod) is module::error) { + match (module::lookup(ctx.mctx, submod)) { + case let ver: module::version => + // TODO: free version data + void; + case module::notfound => continue; + case let err: module::error => + return err; }; append(submodules, dir); @@ -112,7 +118,7 @@ fn emit_submodules(ctx: *context) (void | error) = { defer free(s); yield strings::concat(s, "::", submodules[i]); } else { - yield submodules[i]; + yield strings::dup(submodules[i]); }; defer free(submodule);