commit 6f6c2b63b1dde987fb8d92d65b492360ca5640e6
parent 29e74ff5fb06dd08f9832df4db70818bc9351b93
Author: Lou Woell <lou.woell@posteo.de>
Date:   Wed, 10 Sep 2025 17:16:01 +0200

Catch some errors

- resolve: return void if identifier is a builtin keyword
- resolve & locate: check for missing argument

Diffstat:
Mcmd/harehelper/find.ha | 10+++++++++-
Mcmd/harehelper/locate.ha | 4+++-
2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/cmd/harehelper/find.ha b/cmd/harehelper/find.ha @@ -25,7 +25,14 @@ use os; fn resolve(cmd: getopt::command) void = { - let id = parse::identstr(cmd.args[0])!; + if(len(cmd.args) == 0) fmt::fatal("Expected Argument"); + + let id = match(parse::identstr(cmd.args[0])){ + case let id: ast::ident => + yield id; + case let e: parse::error => + return void; + }; let file = if (len(cmd.args) > 1) { yield cmd.args[1]; @@ -43,6 +50,7 @@ fn resolve(cmd: getopt::command) void = { }; fn list_imports (path: str) []ast::import = { + const input = match (os::open(path)) { case let f: io::file => yield f; diff --git a/cmd/harehelper/locate.ha b/cmd/harehelper/locate.ha @@ -13,7 +13,7 @@ // this program. If not, see <https://www.gnu.org/licenses/>. use fmt; -use getopt :: { command }; +use getopt::{command}; use hare::ast; use hare::lex; use hare::module; @@ -23,6 +23,8 @@ use path; fn locate (cmd: command, ctx: *module::context) void = { + if(len(cmd.args) == 0) fmt::fatal("Expected Argument"); + let id = match (parse::identstr(cmd.args[0])) { case parse::error => return void;