authorgravatar for matthew.h.borkowski@gmail.comMatthew Borkowski <matthew.h.borkowski@gmail.com> 2021-10-23 18:49:23-04:00
committergravatar for matthew.h.borkowski@gmail.comMatthew Borkowski <matthew.h.borkowski@gmail.com> 2021-10-23 18:49:23-04:00
log096763de9808efa996d248815d4ac913381aa1b4
tree360de68f09c5bb95943298b59161293296bba6dd
parentee98d8700818aa667137e3aa580b16df2ba6d680

astgen.zig: fix nodeMayEvalToError


1 files changed, 14 insertions(+), 7 deletions(-)

src/AstGen.zig+14-7
......@@ -8514,10 +8514,10 @@ fn nodeMayEvalToError(tree: *const Ast, start_node: Ast.Node.Index) enum { never
85148514 .unwrap_optional,
85158515 => node = node_datas[node].lhs,
85168516
8517 // Forward the question to the RHS sub-expression.
8517 // LHS sub-expression may still be an error under the outer optional or error union
85188518 .@"catch",
85198519 .@"orelse",
8520 => node = node_datas[node].rhs,
8520 => return .maybe,
85218521
85228522 .block_two,
85238523 .block_two_semicolon,
......@@ -8544,11 +8544,18 @@ fn nodeMayEvalToError(tree: *const Ast, start_node: Ast.Node.Index) enum { never
85448544 // If the builtin is an invalid name, we don't cause an error here; instead
85458545 // let it pass, and the error will be "invalid builtin function" later.
85468546 const builtin_info = BuiltinFn.list.get(builtin_name) orelse return .maybe;
8547 if (builtin_info.tag == .err_set_cast) {
8548 return .always;
8549 } else {
8550 return .never;
8551 }
8547 return switch (builtin_info.tag) {
8548 .as,
8549 .call,
8550 .field,
8551 => .maybe,
8552
8553 .err_set_cast,
8554 .int_to_error,
8555 => .always,
8556
8557 else => .never,
8558 };
85528559 },
85538560 }
85548561 }