mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
stage2: cmp_eq between untyped undefines values results in undef bool
This commit is contained in:
parent
3e99495ed8
commit
970f954039
@ -9244,9 +9244,9 @@ fn cmpSelf(
|
||||
const resolved_type = sema.typeOf(casted_lhs);
|
||||
const runtime_src: LazySrcLoc = src: {
|
||||
if (try sema.resolveMaybeUndefVal(block, lhs_src, casted_lhs)) |lhs_val| {
|
||||
if (lhs_val.isUndef()) return sema.addConstUndef(resolved_type);
|
||||
if (lhs_val.isUndef()) return sema.addConstUndef(Type.initTag(.bool));
|
||||
if (try sema.resolveMaybeUndefVal(block, rhs_src, casted_rhs)) |rhs_val| {
|
||||
if (rhs_val.isUndef()) return sema.addConstUndef(resolved_type);
|
||||
if (rhs_val.isUndef()) return sema.addConstUndef(Type.initTag(.bool));
|
||||
|
||||
if (lhs_val.compare(op, rhs_val, resolved_type)) {
|
||||
return Air.Inst.Ref.bool_true;
|
||||
@ -9265,7 +9265,7 @@ fn cmpSelf(
|
||||
// bool eq/neq more efficiently.
|
||||
if (resolved_type.zigTypeTag() == .Bool) {
|
||||
if (try sema.resolveMaybeUndefVal(block, rhs_src, casted_rhs)) |rhs_val| {
|
||||
if (rhs_val.isUndef()) return sema.addConstUndef(resolved_type);
|
||||
if (rhs_val.isUndef()) return sema.addConstUndef(Type.initTag(.bool));
|
||||
return sema.runtimeBoolCmp(block, op, casted_lhs, rhs_val.toBool(), lhs_src);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1024,8 +1024,6 @@ test "vector comparison" {
|
||||
}
|
||||
|
||||
test "compare undefined literal with comptime_int" {
|
||||
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
|
||||
var x = undefined == 1;
|
||||
// x is now undefined with type bool
|
||||
x = true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user