commit 5a19c8454e2f14203b44068afeb3cb1e7fc72125
parent 531217132b53c440ddeea42d5243811c32fde099
Author: Bor Grošelj Simić <bor.groseljsimic@telemach.net>
Date: Tue, 28 Dec 2021 22:10:22 +0100
all: resolve name clashes that weren't noticed before
All these issues surfaced after a bugfix that changed type shadowing
logic in harec.
Signed-off-by: Bor Grošelj Simić <bor.groseljsimic@telemach.net>
Diffstat:
9 files changed, 54 insertions(+), 54 deletions(-)
diff --git a/encoding/utf8/decode.ha b/encoding/utf8/decode.ha
@@ -114,8 +114,8 @@ export fn prev(d: *decoder) (rune | void | more | invalid) = {
assert(prev(&decoder) is void);
// TODO: Test more invalid sequences
- const invalid: [_]u8 = [0xA0, 0xA1];
- decoder = decode(invalid);
+ const inv: [_]u8 = [0xA0, 0xA1];
+ decoder = decode(inv);
assert(next(&decoder) is invalid);
decoder.offs = 2;
assert(prev(&decoder) is more);
diff --git a/format/xml/+test.ha b/format/xml/+test.ha
@@ -81,7 +81,7 @@ use strings;
], true);
};
-fn xmltest(input: str, expected: []token, error: bool) void = {
+fn xmltest(input: str, expected: []token, err: bool) void = {
let in = bufio::fixed(strings::toutf8(input), io::mode::READ);
defer io::close(in);
let parser = parse(in) as *parser;
@@ -109,7 +109,7 @@ fn xmltest(input: str, expected: []token, error: bool) void = {
assert(el == ex);
};
};
- if (error) {
+ if (err) {
assert(scan(parser) is error);
} else {
assert(scan(parser) is void);
diff --git a/hare/module/manifest.ha b/hare/module/manifest.ha
@@ -237,7 +237,7 @@ export fn manifest_load(ctx: *context, ident: ast::ident) (manifest | error) = {
// Returns true if the desired module version is present and current in this
// manifest.
-export fn current(manifest: *manifest, version: *version) bool = {
+export fn current(man: *manifest, ver: *version) bool = {
// TODO: This is kind of dumb. What we really need to do is:
// 1. Update scan to avoid hashing the file if a manifest is present,
// and indicate that the hash is cached somewhere in the type. Get an
@@ -247,9 +247,9 @@ export fn current(manifest: *manifest, version: *version) bool = {
// check the hash and update the manifest to the new inode/mtime if
// the hash matches. If not, the module is not current; rebuild.
let cached: nullable *version = null;
- for (let i = 0z; i < len(manifest.versions); i += 1) {
- if (bytes::equal(manifest.versions[i].hash, version.hash)) {
- cached = &manifest.versions[i];
+ for (let i = 0z; i < len(man.versions); i += 1) {
+ if (bytes::equal(man.versions[i].hash, ver.hash)) {
+ cached = &man.versions[i];
break;
};
};
@@ -260,7 +260,7 @@ export fn current(manifest: *manifest, version: *version) bool = {
yield v;
};
- assert(len(cached.inputs) == len(version.inputs));
+ assert(len(cached.inputs) == len(ver.inputs));
for (let i = 0z; i < len(cached.inputs); i += 1) {
let a = cached.inputs[i], b = cached.inputs[i];
assert(a.path == b.path);
@@ -274,8 +274,8 @@ export fn current(manifest: *manifest, version: *version) bool = {
};
// Writes a module manifest to the build cache.
-export fn manifest_write(ctx: *context, manifest: *manifest) (void | error) = {
- let ipath = identpath(manifest.ident);
+export fn manifest_write(ctx: *context, man: *manifest) (void | error) = {
+ let ipath = identpath(man.ident);
defer free(ipath);
let cachedir = path::join(ctx.cache, ipath);
defer free(cachedir);
@@ -291,14 +291,14 @@ export fn manifest_write(ctx: *context, manifest: *manifest) (void | error) = {
free(name);
};
- let ident = unparse::identstr(manifest.ident);
+ let ident = unparse::identstr(man.ident);
defer free(ident);
fmt::fprintfln(file, "# {}", ident)?;
fmt::fprintln(file, "# This file is an internal Hare implementation detail.")?;
fmt::fprintln(file, "# The format is not stable.")?;
fmt::fprintfln(file, "version {}", VERSION)?;
- for (let i = 0z; i < len(manifest.inputs); i += 1) {
- const input = manifest.inputs[i];
+ for (let i = 0z; i < len(man.inputs); i += 1) {
+ const input = man.inputs[i];
let hash = hex::encodestr(input.hash);
defer free(hash);
@@ -309,8 +309,8 @@ export fn manifest_write(ctx: *context, manifest: *manifest) (void | error) = {
time::unix(input.stat.mtime))?;
};
- for (let i = 0z; i < len(manifest.versions); i += 1) {
- const ver = manifest.versions[i];
+ for (let i = 0z; i < len(man.versions); i += 1) {
+ const ver = man.versions[i];
let hash = hex::encodestr(ver.hash);
defer free(hash);
diff --git a/hare/types/+test.ha b/hare/types/+test.ha
@@ -252,9 +252,9 @@ fn resolve(
let htype = lookup(st, &atype)!;
assert(htype.sz == 4 * 5);
assert(htype.align == 4);
- let array = htype.repr as array;
- assert(array.member.repr as builtin == builtin::I32);
- assert(array.length == 5);
+ let arr = htype.repr as array;
+ assert(arr.member.repr as builtin == builtin::I32);
+ assert(arr.length == 5);
// Unbounded array
let atype = parse_type("[*]i32");
@@ -262,9 +262,9 @@ fn resolve(
let htype = lookup(st, &atype)!;
assert(htype.sz == SIZE_UNDEFINED);
assert(htype.align == 4);
- let array = htype.repr as array;
- assert(array.member.repr as builtin == builtin::I32);
- assert(array.length == SIZE_UNDEFINED);
+ let arr = htype.repr as array;
+ assert(arr.member.repr as builtin == builtin::I32);
+ assert(arr.length == SIZE_UNDEFINED);
// Contextual array (equivalent to unbounded at this compilation stage)
let atype = parse_type("[_]i32");
@@ -272,9 +272,9 @@ fn resolve(
let htype = lookup(st, &atype)!;
assert(htype.sz == SIZE_UNDEFINED);
assert(htype.align == 4);
- let array = htype.repr as array;
- assert(array.member.repr as builtin == builtin::I32);
- assert(array.length == SIZE_UNDEFINED);
+ let arr = htype.repr as array;
+ assert(arr.member.repr as builtin == builtin::I32);
+ assert(arr.length == SIZE_UNDEFINED);
};
@test fn funcs() void = {
diff --git a/hare/unit/process.ha b/hare/unit/process.ha
@@ -140,8 +140,8 @@ fn process_expr(
};
fn process_access(ctx: *context, aexpr: *ast::expr) (*expr | error) = {
- const access = aexpr.expr as ast::access_expr;
- const op: (const *types::_type, access) = match (access) {
+ const access_expr = aexpr.expr as ast::access_expr;
+ const op: (const *types::_type, access) = match (access_expr) {
case let ai: ast::access_identifier =>
const object = match (ctx_lookup(ctx, ai)) {
case null =>
@@ -222,13 +222,13 @@ fn process_binding(ctx: *context, aexpr: *ast::expr) (*expr | error) = {
};
fn process_compound(ctx: *context, aexpr: *ast::expr) (*expr | error) = {
- const compound = aexpr.expr as ast::compound_expr;
+ const compound_expr = aexpr.expr as ast::compound_expr;
const scope = scope_push(ctx, scope_class::COMPOUND);
- let exprs: compound = alloc([], len(compound.exprs));
+ let exprs: compound = alloc([], len(compound_expr.exprs));
let i = 0z;
- for (i < len(compound.exprs); i += 1) {
- append(exprs, process_expr(ctx, compound.exprs[i])?);
+ for (i < len(compound_expr.exprs); i += 1) {
+ append(exprs, process_expr(ctx, compound_expr.exprs[i])?);
};
scope_pop(ctx);
@@ -387,18 +387,18 @@ fn process_return(ctx: *context, aexpr: *ast::expr) (*expr | error) = {
defer freetestctx(&ctx);
const aexpr = parse_expr("return;");
defer ast::expr_free(aexpr);
- const expr = process_return(&ctx, aexpr)!;
- assert(expr.terminates);
- assert(expr.result.repr as types::builtin == types::builtin::VOID);
- const rval = expr.expr as _return;
+ const ret_expr = process_return(&ctx, aexpr)!;
+ assert(ret_expr.terminates);
+ assert(ret_expr.result.repr as types::builtin == types::builtin::VOID);
+ const rval = ret_expr.expr as _return;
assert(rval == null);
const aexpr = parse_expr("return 10;");
defer ast::expr_free(aexpr);
- const expr = process_return(&ctx, aexpr)!;
- assert(expr.terminates);
- assert(expr.result.repr as types::builtin == types::builtin::VOID);
- const rval = expr.expr as _return;
+ const ret_expr = process_return(&ctx, aexpr)!;
+ assert(ret_expr.terminates);
+ assert(ret_expr.result.repr as types::builtin == types::builtin::VOID);
+ const rval = ret_expr.expr as _return;
assert(rval != null);
assert((rval: *expr).expr is constant);
};
diff --git a/hare/unit/scope.ha b/hare/unit/scope.ha
@@ -60,9 +60,9 @@ fn scope_push(ctx: *context, class: scope_class) *scope = {
};
fn scope_pop(ctx: *context) *scope = {
- const scope = ctx.scope;
+ const top_scope = ctx.scope;
ctx.scope = ctx.scope.parent: *scope; // TODO: as *scope
- return scope;
+ return top_scope;
};
fn ident_hash(ident: ast::ident) u64 = {
@@ -88,19 +88,19 @@ fn scope_insert(ctx: *context, obj: object) *object = {
fn ctx_lookup(ctx: *context, ident: ast::ident) nullable *object =
scope_lookup(ctx.scope, ident);
-fn scope_lookup(scope: *scope, ident: ast::ident) nullable *object = {
+fn scope_lookup(scp: *scope, ident: ast::ident) nullable *object = {
const hash = ident_hash(ident);
- const bucket = scope.hashmap[hash: size % SCOPE_BUCKETS];
+ const bucket = scp.hashmap[hash: size % SCOPE_BUCKETS];
for (let i = 0z; i < len(bucket); i += 1) {
if (ast::ident_eq(bucket[i].name, ident)
|| ast::ident_eq(bucket[i].ident, ident)) {
return bucket[i];
};
};
- match (scope.parent) {
+ match (scp.parent) {
case null =>
return null;
- case let scope: *scope =>
- return scope_lookup(scope, ident);
+ case let s: *scope =>
+ return scope_lookup(s, ident);
};
};
diff --git a/io/+linux/file.ha b/io/+linux/file.ha
@@ -41,10 +41,10 @@ fn fd_close(fd: file) void = rt::close(fd)!;
fn fd_seek(
fd: file,
- off: off,
+ offs: off,
whence: whence,
) (off | error) = {
- match (rt::lseek(fd, off: i64, whence: uint)) {
+ match (rt::lseek(fd, offs: i64, whence: uint)) {
case let err: rt::errno =>
return errors::errno(err);
case let n: i64 =>
diff --git a/net/ip/ip.ha b/net/ip/ip.ha
@@ -354,10 +354,10 @@ fn wanttoken(tok: *strings::tokenizer) (str | invalid) = {
// Returns whether an [[addr]] (or another [[subnet]]) is contained
// within a [[subnet]].
export fn subnet_contains(sub: subnet, item: (addr | subnet)) bool = {
- let addr: subnet = match (item) {
- case let addr: addr =>
+ let a: subnet = match (item) {
+ case let a: addr =>
yield subnet{
- addr = addr,
+ addr = a,
mask = sub.mask,
};
case let sub: subnet =>
@@ -372,11 +372,11 @@ export fn subnet_contains(sub: subnet, item: (addr | subnet)) bool = {
case let v4: addr4 => yield v4[..];
case let v6: addr6 => yield v6[..];
};
- let ipb = match (addr.addr) {
+ let ipb = match (a.addr) {
case let v4: addr4 => yield v4[..];
case let v6: addr6 => yield v6[..];
};
- let maskb = match (addr.mask) {
+ let maskb = match (a.mask) {
case let v4: addr4 => yield v4[..];
case let v6: addr6 => yield v6[..];
};
diff --git a/strings/sub.ha b/strings/sub.ha
@@ -46,7 +46,7 @@ export fn sub(s: str, start: size, end: (size | end)) str = {
let endi = match (end) {
case let sz: size =>
yield starti + utf8_byte_len_bounded(&iter, sz - start);
- case end =>
+ case =>
yield starti + utf8_byte_len_unbounded(&iter);
};
let bytes = toutf8(s);