Skip to content

Commit

Permalink
Fix #4229 for edge case os.Error/os.Errno legacy bodge
Browse files Browse the repository at this point in the history
  • Loading branch information
gingerBill committed Sep 11, 2024
1 parent b379d25 commit 9b06ea5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/check_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4602,7 +4602,7 @@ gb_internal void convert_to_typed(CheckerContext *c, Operand *operand, Type *tar
(operand->value.kind == ExactValue_Integer ||
operand->value.kind == ExactValue_Float)) {
operand->mode = Addressing_Value;
target_type = t_untyped_nil;
// target_type = t_untyped_nil;
operand->value = empty_exact_value;
update_untyped_expr_value(c, operand->expr, operand->value);
break;
Expand Down
8 changes: 7 additions & 1 deletion src/llvm_backend_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3451,8 +3451,14 @@ gb_internal lbValue lb_build_expr_internal(lbProcedure *p, Ast *expr) {

switch (expr->kind) {
case_ast_node(bl, BasicLit, expr);
if (type != nullptr && type->Named.name == "Error") {
Entity *e = type->Named.type_name;
if (e->pkg && e->pkg->name == "os") {
return lb_const_nil(p->module, type);
}
}
TokenPos pos = bl->token.pos;
GB_PANIC("Non-constant basic literal %s - %.*s", token_pos_to_string(pos), LIT(token_strings[bl->token.kind]));
GB_PANIC("Non-constant basic literal %s - %.*s (%s)", token_pos_to_string(pos), LIT(token_strings[bl->token.kind]), type_to_string(type));
case_end;

case_ast_node(bd, BasicDirective, expr);
Expand Down

0 comments on commit 9b06ea5

Please sign in to comment.