# \[Pitch\] Property-Based Type Narrowing and Union Types

**URL:** <https://forums.swift.org/t/pitch-property-based-type-narrowing-and-union-types/78871>\
**Category:** Pitches\
**Tags:** swift\
**Created:** [March 26, 2025, 10:33pm UTC](https://forums.swift.org/t/pitch-property-based-type-narrowing-and-union-types/78871 "2025-03-26T22:33:45Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![YOCKOW](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/yockow/32/20636_2.png) [@YOCKOW](https://forums.swift.org/u/YOCKOW)\
**Post date:** [March 27, 2025, 4:07am UTC](https://forums.swift.org/t/pitch-property-based-type-narrowing-and-union-types/78871/5 "2025-03-27T04:07:03Z")

</div>

🤔I think "Union Types" is listed in [Commonly Rejected Changes](https://github.com/swiftlang/swift-evolution/blob/main/commonly_proposed.md).

> - [Disjunctions (logical ORs) in type constraints](https://forums.swift.org/t/returned-for-revision-se-0095-replace-protocol-p1-p2-syntax-with-any-p1-p2/2855): These include anonymous union-like types (e.g. `(Int | String)` for a type that can be inhabited by either an integer or a string). "[This type of constraint is] something that the type system cannot and should not support."

* * *

> [@amyworrall](#):
>
> Would this now be valid?
> 
> ```swift
> if foo != nil {
> foo.doSomething()
> }
> 
> ```

That is source breaking change:

> [@Let's fix \`if let\` syntax](https://forums.swift.org/t/lets-fix-if-let-syntax/48188/30):
>
> About `if value != nil`, it is really problematic. Currently this code works.
> 
> ```swift
> var value: Int? = 42
> // some process
> if value != nil {
> // some process     
> // finally make value nil
> value = nil
> }
> 
> ```
> 
> If Swift introduces `if value != nil` that implicitly unwraps `value`, it starts causing error, because `value` inside `if` is no longer `Int?` but `Int`. It's **source breaking** change actually.

---

_[View the full topic](https://forums.swift.org/t/pitch-property-based-type-narrowing-and-union-types/78871)._
