mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 13:30:45 +00:00
astgen.zig: fix nodeMayEvalToError
This commit is contained in:
parent
ee98d87008
commit
096763de98
@ -8514,10 +8514,10 @@ fn nodeMayEvalToError(tree: *const Ast, start_node: Ast.Node.Index) enum { never
|
||||
.unwrap_optional,
|
||||
=> node = node_datas[node].lhs,
|
||||
|
||||
// Forward the question to the RHS sub-expression.
|
||||
// LHS sub-expression may still be an error under the outer optional or error union
|
||||
.@"catch",
|
||||
.@"orelse",
|
||||
=> node = node_datas[node].rhs,
|
||||
=> return .maybe,
|
||||
|
||||
.block_two,
|
||||
.block_two_semicolon,
|
||||
@ -8544,11 +8544,18 @@ fn nodeMayEvalToError(tree: *const Ast, start_node: Ast.Node.Index) enum { never
|
||||
// If the builtin is an invalid name, we don't cause an error here; instead
|
||||
// let it pass, and the error will be "invalid builtin function" later.
|
||||
const builtin_info = BuiltinFn.list.get(builtin_name) orelse return .maybe;
|
||||
if (builtin_info.tag == .err_set_cast) {
|
||||
return .always;
|
||||
} else {
|
||||
return .never;
|
||||
}
|
||||
return switch (builtin_info.tag) {
|
||||
.as,
|
||||
.call,
|
||||
.field,
|
||||
=> .maybe,
|
||||
|
||||
.err_set_cast,
|
||||
.int_to_error,
|
||||
=> .always,
|
||||
|
||||
else => .never,
|
||||
};
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user