commit 06b3f5b77a6aa1247dfbf2972b7f2238493b2c8f
parent f773a83019590e7287c361944e0c7b52505ceb9d
Author: Alexey Yerin <yyp@disroot.org>
Date: Fri, 12 Nov 2021 12:59:17 +0300
all: fix incomplete structs
Thanks to brand new harec struct exhaustivity testing.
Signed-off-by: Alexey Yerin <yyp@disroot.org>
Diffstat:
14 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/fs/mem/mem.ha b/fs/mem/mem.ha
@@ -58,8 +58,10 @@ export fn memopen() *fs::fs = alloc(inode {
data = empty_dir(),
name = "",
hash = hash_of(""),
+ next = null,
opencount = 1,
parent = null,
+ ...
});
fn file_flags(flags: fs::flags...) ((io::mode, bool) | fs::error) = {
@@ -135,6 +137,7 @@ fn stat(fs: *fs::fs, path: str) (fs::filestat | fs::error) = {
mode = fs::mode::REG | 0o777,
mask = fs::stat_mask::SIZE,
sz = len(f),
+ ...
};
};
};
@@ -167,8 +170,10 @@ fn mksubdir(fs: *fs::fs, path: str) (*fs::fs | fs::error) = {
data = empty_dir(),
name = strings::dup(name),
hash = hash_of(name),
+ next = null,
opencount = 1,
parent = parent,
+ ...
});
inode_insert(parent, ino);
return ino;
diff --git a/hare/module/manifest.ha b/hare/module/manifest.ha
@@ -169,6 +169,7 @@ export fn manifest_load(ctx: *context, ident: ast::ident) (manifest | error) = {
mask = fs::stat_mask::MTIME | fs::stat_mask::INODE,
mtime = mtime,
inode = inode,
+ ...
},
basename = strings::dup(parsed.0),
tags = parsed.2,
@@ -215,6 +216,7 @@ export fn manifest_load(ctx: *context, ident: ast::ident) (manifest | error) = {
append(versions, version {
hash = modhash,
inputs = minputs,
+ ...
});
case =>
return manifest;
diff --git a/hare/module/scan.ha b/hare/module/scan.ha
@@ -60,6 +60,7 @@ export fn scan(ctx: *context, path: str) (version | error) = {
basedir = path::dirname(fs::resolve(ctx.fs, path)),
depends = deps,
inputs = inputs,
+ ...
};
case err: fs::error =>
return err;
diff --git a/hare/types/hash.ha b/hare/types/hash.ha
@@ -168,6 +168,7 @@ export fn hash(t: *_type) u32 = {
let sample = _type {
flags = flags::NONE,
repr = builtin::STR,
+ ...
};
assert(hash(&sample) == 2843771249);
@@ -177,6 +178,7 @@ export fn hash(t: *_type) u32 = {
id = ["foo", "bar"],
...
},
+ ...
};
assert(hash(&sample) == 385303307);
@@ -186,12 +188,14 @@ export fn hash(t: *_type) u32 = {
id = ["foo", "bar"],
...
},
+ ...
};
assert(hash(&sample) == 4117101293);
let _int = _type {
flags = flags::NONE,
repr = builtin::INT,
+ ...
};
assert(hash(&_int) == 1099590421);
@@ -201,6 +205,7 @@ export fn hash(t: *_type) u32 = {
referent = &_int,
flags = pointer_flags::NONE,
},
+ ...
};
assert(hash(&sample) == 2081672869);
@@ -210,6 +215,7 @@ export fn hash(t: *_type) u32 = {
referent = &_int,
flags = pointer_flags::NULLABLE,
},
+ ...
};
assert(hash(&sample) == 841481858);
@@ -230,6 +236,7 @@ export fn hash(t: *_type) u32 = {
},
],
},
+ ...
};
assert(hash(&sample) == 2453524063);
@@ -249,6 +256,7 @@ export fn hash(t: *_type) u32 = {
_type = &_int,
},
],
+ ...
};
assert(hash(&sample) == 2230759349);
@@ -258,16 +266,19 @@ export fn hash(t: *_type) u32 = {
length = 5,
member = &_int,
},
+ ...
};
assert(hash(&sample) == 3903522747);
let _uint = _type {
flags = flags::NONE,
repr = builtin::UINT,
+ ...
};
let _void = _type {
flags = flags::NONE,
repr = builtin::VOID,
+ ...
};
let sample = _type {
@@ -277,6 +288,7 @@ export fn hash(t: *_type) u32 = {
&_uint,
&_void,
]: tagged,
+ ...
};
assert(hash(&sample) == 2847927164);
@@ -290,6 +302,7 @@ export fn hash(t: *_type) u32 = {
("BAZ", 69),
],
},
+ ...
};
assert(hash(&sample) == 94471087);
@@ -301,12 +314,14 @@ export fn hash(t: *_type) u32 = {
flags = func_flags::NORETURN,
params = [&_uint, &_int],
},
+ ...
};
assert(hash(&sample) == 1223530078);
let sample = _type {
flags = flags::NONE,
repr = &_void: slice,
+ ...
};
assert(hash(&sample) == 263911532);
};
diff --git a/hare/types/store.ha b/hare/types/store.ha
@@ -283,6 +283,7 @@ fn fromast(store: *typestore, atype: *ast::_type) (_type | deferred | error) = {
sz += align - (sz - align) % align;
};
return _type {
+ id = 0, // filled in later
flags = atype.flags: flags,
repr = repr,
sz = sz,
diff --git a/hare/unit/+test.ha b/hare/unit/+test.ha
@@ -16,6 +16,7 @@ fn parse_expr(src: str) *ast::expr = {
fn mktestctx() context = context {
store = types::store(types::x86_64, null, null),
scope = alloc(scope { ... }),
+ ...
};
fn freetestctx(ctx: *context) void = {
diff --git a/hare/unit/check.ha b/hare/unit/check.ha
@@ -12,6 +12,7 @@ export fn check(
let ctx = context {
store = store,
scope = alloc(scope { class = scope_class::UNIT, ... }),
+ ...
};
scan(&ctx, subunits)?;
return process(&ctx, subunits);
diff --git a/hare/unit/process.ha b/hare/unit/process.ha
@@ -162,6 +162,7 @@ fn process_access(ctx: *context, aexpr: *ast::expr) (*expr | error) = {
end = aexpr.end,
result = op.0,
expr = op.1,
+ terminates = false,
});
};
@@ -174,6 +175,7 @@ fn process_access(ctx: *context, aexpr: *ast::expr) (*expr | error) = {
ident = ["hello"],
name = ["hello"],
_type = &types::builtin_u32,
+ ...
});
const aexpr = parse_expr("hello");
defer ast::expr_free(aexpr);
diff --git a/hare/unit/scan.ha b/hare/unit/scan.ha
@@ -60,6 +60,7 @@ fn scan_func(
ident = ast::ident_dup(func.ident),
name = ast::ident_dup(func.ident),
_type = fntype,
+ ...
});
return;
};
diff --git a/hare/unparse/decl.ha b/hare/unparse/decl.ha
@@ -141,6 +141,7 @@ fn decl_test(d: ast::decl, expected: str) bool = {
decl = [
ast::decl_global {
is_const = false,
+ is_hidden = false,
symbol = "",
ident = ["foo", "bar"],
_type = type_int,
@@ -148,12 +149,14 @@ fn decl_test(d: ast::decl, expected: str) bool = {
},
ast::decl_global {
is_const = false,
+ is_hidden = false,
symbol = "foobar",
ident = ["baz"],
_type = type_int,
init = alloc(expr_void),
},
],
+ ...
};
assert(decl_test(d, "let foo::bar: int = void, @symbol(\"foobar\") baz: int = void;"));
diff --git a/hash/crc32/crc32.ha b/hash/crc32/crc32.ha
@@ -198,6 +198,7 @@ export fn crc32(table: *[256]u32) state = state {
sz = SIZE,
table = table,
cval = ~0u32,
+ ...
};
fn write(s: *io::stream, buf: const []u8) (size | io::error) = {
diff --git a/io/filestream.ha b/io/filestream.ha
@@ -10,6 +10,7 @@ export type filestream = struct {
// necessary for most programs; most APIs should accept [[handle]] instead of
// [[stream]] in order to support both file-oriented and stream-oriented I/O.
export fn fdstream(fd: file) filestream = filestream {
+ fd = fd,
reader = &fdstream_read,
writer = &fdstream_write,
closer = &fdstream_close,
diff --git a/iobus/io_uring/bus.ha b/iobus/io_uring/bus.ha
@@ -18,6 +18,7 @@ export fn new() (*bus | error) = {
case ring: io_uring::io_uring =>
return alloc(bus {
uring = ring,
+ ...
});
};
};
@@ -132,6 +133,7 @@ export fn unregister_file(bus: *bus, file: file) void = {
io_uring::files_update {
offs = reg: u32,
fds = &bus.fdset[reg],
+ ...
},
];
bus.fdset[reg] = -1;
diff --git a/os/+linux/dirfdfs.ha b/os/+linux/dirfdfs.ha
@@ -83,6 +83,7 @@ fn static_dirfdopen(fd: io::file, filesystem: *os_filesystem) *fs::fs = {
},
dirfd = fd,
getdents_bufsz = 32768, // 32 KiB
+ ...
};
return &filesystem.fs;
};
@@ -272,7 +273,7 @@ fn fs_stat(fs: *fs::fs, path: str) (fs::filestat | fs::error) = {
| fs::stat_mask::CTIME,
mode = st.mode: fs::mode,
uid = st.uid,
- uid = st.gid,
+ gid = st.gid,
sz = st.sz,
inode = st.ino,
atime = time::instant {