commit 1d1b6fdcbd58321de5c92c0e18cc50bcc4698467
parent 864169e8a96972dbdd02f65d991799704db109f2
Author: Lou Woell <lou.woell@posteo.de>
Date: Mon, 16 Feb 2026 18:23:39 +0100
Hare-0.26: Multiple assignment no longer supported.
Diffstat:
3 files changed, 75 insertions(+), 87 deletions(-)
diff --git a/cmd/harehelper/+test/locate_test.ha b/cmd/harehelper/+test/locate_test.ha
@@ -7,8 +7,11 @@ use os;
use test;
use strings;
-def q = 1, w = 2;
-const s = 1, d = 2;
+def q = 1;
+def w = 2;
+
+const s = 1;
+const d = 2;
fn loc_test_fn (in: str, out: lex::location) void = {
@@ -52,8 +55,8 @@ fn loc_test_fn (in: str, out: lex::location) void = {
@test fn locate_local_tag_from_root() void = {
loc_test_fn("cmd::harehelper::loc_test_fn", lex::location {
path = "locate_test.ha",
- line = 11,
- col = 20,
+ line = 16,
+ col = 1,
...
});
};
@@ -61,47 +64,47 @@ fn loc_test_fn (in: str, out: lex::location) void = {
@test fn locate_local_from_root() void = {
loc_test_fn("cmd::harehelper::locate", lex::location {
path = "locate.ha",
- line = 23,
- col = 13,
- ...
- });
-};
-
-@test fn locate_global_multiple1 () void = {
- loc_test_fn("cmd::harehelper::s", lex::location {
- path = "locate_test.ha",
- line = 10,
- col = 18,
- ...
- });
-};
-
-@test fn locate_global_multiple2 () void = {
- loc_test_fn("cmd::harehelper::d", lex::location {
- path = "locate_test.ha",
- line = 10,
- col = 18,
- ...
- });
-};
-
-@test fn locate_const_multiple1 () void = {
- loc_test_fn("cmd::harehelper::q", lex::location {
- path = "locate_test.ha",
- line = 8,
- col = 13,
- ...
- });
-};
-
-@test fn locate_const_multiple2 () void = {
- loc_test_fn("cmd::harehelper::w", lex::location {
- path = "locate_test.ha",
- line = 8,
- col = 13,
- ...
- });
-};
+ line = 25,
+ col = 1,
+ ...
+ });
+};
+
+// @test fn locate_global_multiple1 () void = {
+// loc_test_fn("cmd::harehelper::s", lex::location {
+// path = "locate_test.ha",
+// line = 10,
+// col = 18,
+// ...
+// });
+// };
+
+// @test fn locate_global_multiple2 () void = {
+// loc_test_fn("cmd::harehelper::d", lex::location {
+// path = "locate_test.ha",
+// line = 10,
+// col = 18,
+// ...
+// });
+// };
+
+// @test fn locate_const_multiple1 () void = {
+// loc_test_fn("cmd::harehelper::q", lex::location {
+// path = "locate_test.ha",
+// line = 8,
+// col = 13,
+// ...
+// });
+// };
+
+// @test fn locate_const_multiple2 () void = {
+// loc_test_fn("cmd::harehelper::w", lex::location {
+// path = "locate_test.ha",
+// line = 8,
+// col = 13,
+// ...
+// });
+// };
@test fn locate_module () void = {
loc_test_fn("os", lex::location {
@@ -135,8 +138,8 @@ fn loc_test_fn (in: str, out: lex::location) void = {
os::chdir("./cmd/harehelper/+test")!;
loc_test_fn("loc_test_fn", lex::location {
path = "locate_test.ha",
- line = 11,
- col = 20,
+ line = 16,
+ col = 1,
...
});
};
@@ -145,8 +148,8 @@ fn loc_test_fn (in: str, out: lex::location) void = {
os::chdir("./cmd/harehelper")!;
loc_test_fn("loc_test_fn", lex::location {
path = "locate_test.ha",
- line = 11,
- col = 20,
+ line = 16,
+ col = 1,
...
});
};
@@ -174,8 +177,8 @@ fn loc_test_fn (in: str, out: lex::location) void = {
os::chdir("./cmd/harehelper")!;
loc_test_fn("locate", lex::location {
path = "locate.ha",
- line = 23,
- col = 13,
+ line = 25,
+ col = 1,
...
});
};
@@ -184,8 +187,8 @@ fn loc_test_fn (in: str, out: lex::location) void = {
os::chdir("./cmd/harehelper/+test")!;
loc_test_fn("locate", lex::location {
path = "locate.ha",
- line = 23,
- col = 13,
+ line = 25,
+ col = 1,
...
});
};
diff --git a/cmd/harehelper/list_symbols.ha b/cmd/harehelper/list_symbols.ha
@@ -78,21 +78,15 @@ fn list_symbols (
for (let d .. decls) {
if (!d.exported && !unexp) continue;
match (d.decl) {
- case let d: []ast::decl_const =>
- for (let t .. d) {
- append(res, ast::ident_dup(t.ident))!;
- };
- case let d: []ast::decl_global =>
- for (let t .. d) {
- append(res, ast::ident_dup(t.ident))!;
- };
- case let d: []ast::decl_type =>
- for (let t .. d) {
- append(res, ast::ident_dup(t.ident))!;
- };
+ case let d: ast::decl_const =>
+ append(res, ast::ident_dup(d.ident))!;
+ case let d: ast::decl_global =>
+ append(res, ast::ident_dup(d.ident))!;
+ case let d: ast::decl_type =>
+ append(res, ast::ident_dup(d.ident))!;
case let d: ast::decl_func =>
append(res, ast::ident_dup(d.ident))!;
- case let d: ast::assert_expr => void;
+ case ast::assert_expr => void;
};
};
};
diff --git a/cmd/harehelper/locate.ha b/cmd/harehelper/locate.ha
@@ -59,7 +59,7 @@ fn locate_symbol (
let p = path::init(os::getcwd())!;
let dirname = match (path::peek(&p)) {
case void =>
- yield "/";
+ yield "/";
case let s: str =>
yield s;
};
@@ -120,31 +120,22 @@ fn locate_symbol (
let found = false;
match (decl.decl) {
- case let d: []ast::decl_const =>
- for (let t .. d) {
- found = ast::ident_eq(ident_last(id), t.ident);
- if (found) break;
- };
- case let d: []ast::decl_global =>
- for (let t .. d) {
- found = ast::ident_eq(ident_last(id), t.ident);
- if (found) break;
- };
- case let d: []ast::decl_type =>
- for (let t .. d) {
- found = ast::ident_eq(ident_last(id), t.ident);
- if (found) break;
- };
+ case let d: ast::decl_const =>
+ found = ast::ident_eq(ident_last(id), d.ident);
+ case let d: ast::decl_global =>
+ found = ast::ident_eq(ident_last(id), d.ident);
+ case let d: ast::decl_type =>
+ found = ast::ident_eq(ident_last(id), d.ident);
case let d: ast::decl_func =>
found = ast::ident_eq(ident_last(id), d.ident);
- case => void;
+ case ast::assert_expr => void;
};
if (found) return lex::location {
- path = strings::dup(decl.start.path)!,
- line = decl.start.line,
- col = decl.start.col,
- off = decl.start.off,
+ path = strings::dup(decl.loc.start.path)!,
+ line = decl.loc.start.line,
+ col = decl.loc.start.col,
+ off = decl.loc.start.off,
};
};
};