Browse Source

Disallow `err != 0` with `os.Error` when `-strict-style` is enabled

gingerBill 1 year ago
parent
commit
0bedd3357a
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/check_expr.cpp

+ 2 - 1
src/check_expr.cpp

@@ -4461,7 +4461,8 @@ gb_internal void convert_to_typed(CheckerContext *c, Operand *operand, Type *tar
 	case Type_Union:
 	case Type_Union:
 		// IMPORTANT NOTE HACK(bill): This is just to allow for comparisons against `0` with the `os.Error` type
 		// IMPORTANT NOTE HACK(bill): This is just to allow for comparisons against `0` with the `os.Error` type
 		// as a kind of transition period
 		// as a kind of transition period
-		if (operand->mode == Addressing_Constant &&
+		if (!build_context.strict_style &&
+		    operand->mode == Addressing_Constant &&
 		    target_type->kind == Type_Named &&
 		    target_type->kind == Type_Named &&
 		    (c->pkg == nullptr || c->pkg->name != "os") &&
 		    (c->pkg == nullptr || c->pkg->name != "os") &&
 		    target_type->Named.name == "Error") {
 		    target_type->Named.name == "Error") {