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...@@ -8514,10 +8514,10 @@ fn nodeMayEvalToError(tree: *const Ast, start_node: Ast.Node.Index) enum { never
8514 .unwrap_optional,8514 .unwrap_optional,
8515 => node = node_datas[node].lhs,8515 => 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
8518 .@"catch",8518 .@"catch",
8519 .@"orelse",8519 .@"orelse",
8520 => node = node_datas[node].rhs,8520 => return .maybe,
85218521
8522 .block_two,8522 .block_two,
8523 .block_two_semicolon,8523 .block_two_semicolon,
...@@ -8544,11 +8544,18 @@ fn nodeMayEvalToError(tree: *const Ast, start_node: Ast.Node.Index) enum { never...@@ -8544,11 +8544,18 @@ fn nodeMayEvalToError(tree: *const Ast, start_node: Ast.Node.Index) enum { never
8544 // If the builtin is an invalid name, we don't cause an error here; instead8544 // If the builtin is an invalid name, we don't cause an error here; instead
8545 // let it pass, and the error will be "invalid builtin function" later.8545 // let it pass, and the error will be "invalid builtin function" later.
8546 const builtin_info = BuiltinFn.list.get(builtin_name) orelse return .maybe;8546 const builtin_info = BuiltinFn.list.get(builtin_name) orelse return .maybe;
8547 if (builtin_info.tag == .err_set_cast) {8547 return switch (builtin_info.tag) {
8548 return .always;8548 .as,
8549 } else {8549 .call,
8550 return .never;8550 .field,
8551 }8551 => .maybe,
8552
8553 .err_set_cast,
8554 .int_to_error,
8555 => .always,
8556
8557 else => .never,
8558 };
8552 },8559 },
8553 }8560 }
8554 }8561 }