wasm: Initial behavior tests succeeding
Note: This also fixes a memory leak for inferred error sets, and for usingnamespace
This commit is contained in:
@@ -1226,19 +1226,20 @@ pub const Fn = struct {
|
||||
};
|
||||
|
||||
pub fn deinit(func: *Fn, gpa: Allocator) void {
|
||||
if (func.getInferredErrorSet()) |map| {
|
||||
map.deinit(gpa);
|
||||
if (func.getInferredErrorSet()) |error_set_data| {
|
||||
error_set_data.map.deinit(gpa);
|
||||
error_set_data.functions.deinit(gpa);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn getInferredErrorSet(func: *Fn) ?*std.StringHashMapUnmanaged(void) {
|
||||
pub fn getInferredErrorSet(func: *Fn) ?*Type.Payload.ErrorSetInferred.Data {
|
||||
const ret_ty = func.owner_decl.ty.fnReturnType();
|
||||
if (ret_ty.tag() == .generic_poison) {
|
||||
return null;
|
||||
}
|
||||
if (ret_ty.zigTypeTag() == .ErrorUnion) {
|
||||
if (ret_ty.errorUnionSet().castTag(.error_set_inferred)) |payload| {
|
||||
return &payload.data.map;
|
||||
return &payload.data;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -1301,6 +1302,7 @@ pub const Namespace = struct {
|
||||
key.destroy(mod);
|
||||
}
|
||||
anon_decls.deinit(gpa);
|
||||
ns.usingnamespace_set.deinit(gpa);
|
||||
}
|
||||
|
||||
pub fn deleteAllDecls(
|
||||
@@ -1332,6 +1334,8 @@ pub const Namespace = struct {
|
||||
child_decl.destroy(mod);
|
||||
}
|
||||
anon_decls.deinit(gpa);
|
||||
|
||||
ns.usingnamespace_set.deinit(gpa);
|
||||
}
|
||||
|
||||
// This renders e.g. "std.fs.Dir.OpenOptions"
|
||||
|
||||
Reference in New Issue
Block a user