hare

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

commit be3282a8fb21490a425d1ec275b05a0de30c8a3f
parent 40f085ca4dc79fe84b928b0f581fd663e425fcea
Author: Alexey Yerin <yyp@disroot.org>
Date:   Thu, 24 Aug 2023 11:00:28 +0300

hare/module: tolerate empty extension

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

Diffstat:
Mhare/module/scan.ha | 14+++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/hare/module/scan.ha b/hare/module/scan.ha @@ -342,11 +342,15 @@ export fn lookup(ctx: *context, name: ast::ident) (version | error) = { fn type_for_ext(name: str) (filetype | void) = { static let buf = path::buffer {...}; path::set(&buf, name)!; - const ext = path::peek_ext(&buf) as str; - return - if (ext == "ha") filetype::HARE - else if (ext == "s") filetype::ASSEMBLY - else void; + match (path::peek_ext(&buf)) { + case let ext: str => + switch (ext) { + case "ha" => return filetype::HARE; + case "s" => return filetype::ASSEMBLY; + case => void; + }; + case => void; + }; }; fn scan_file(