mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 19:38:58 +00:00
Passthrough anyerror when using handleOom (#23176)
### What does this PR do? Previously, handleOom(anyerror!T) would return T and panic for OutOfMemory for any error. fixes it to return anyerror!T for this case. ### How did you verify your code works? CI --------- Co-authored-by: taylor.fish <contact@taylor.fish>
This commit is contained in:
@@ -210,7 +210,7 @@ pub fn ParseTypescript(
|
||||
p.popScope();
|
||||
|
||||
if (!opts.is_typescript_declare) {
|
||||
name.ref = bun.handleOom(p.declareSymbol(.ts_namespace, name_loc, name_text));
|
||||
name.ref = try p.declareSymbol(.ts_namespace, name_loc, name_text);
|
||||
try p.ref_to_ts_namespace_member.put(p.allocator, name.ref.?, ns_member_data);
|
||||
}
|
||||
|
||||
|
||||
@@ -1315,10 +1315,10 @@ pub fn VisitStmt(
|
||||
try p.top_level_enums.append(p.allocator, data.name.ref.?);
|
||||
}
|
||||
|
||||
bun.handleOom(p.recordDeclaredSymbol(data.name.ref.?));
|
||||
bun.handleOom(p.pushScopeForVisitPass(.entry, stmt.loc));
|
||||
try p.recordDeclaredSymbol(data.name.ref.?);
|
||||
try p.pushScopeForVisitPass(.entry, stmt.loc);
|
||||
defer p.popScope();
|
||||
bun.handleOom(p.recordDeclaredSymbol(data.arg));
|
||||
try p.recordDeclaredSymbol(data.arg);
|
||||
|
||||
const allocator = p.allocator;
|
||||
// Scan ahead for any variables inside this namespace. This must be done
|
||||
@@ -1327,7 +1327,7 @@ pub fn VisitStmt(
|
||||
// We need to convert the uses into property accesses on the namespace.
|
||||
for (data.values) |value| {
|
||||
if (value.ref.isValid()) {
|
||||
bun.handleOom(p.is_exported_inside_namespace.put(allocator, value.ref, data.arg));
|
||||
try p.is_exported_inside_namespace.put(allocator, value.ref, data.arg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1336,7 +1336,7 @@ pub fn VisitStmt(
|
||||
// without initializers are initialized to undefined.
|
||||
var next_numeric_value: ?f64 = 0.0;
|
||||
|
||||
var value_exprs = bun.handleOom(ListManaged(Expr).initCapacity(allocator, data.values.len));
|
||||
var value_exprs = try ListManaged(Expr).initCapacity(allocator, data.values.len);
|
||||
|
||||
var all_values_are_pure = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user