jank icon indicating copy to clipboard operation
jank copied to clipboard

Support for common types in `if`

Open shantanu-sardesai opened this issue 2 months ago • 0 comments

Although we can't support common types in cases of value types or refs due to object slicing concerns. We could potentially add support for common types in cases of pointers.

Example

user=> (cpp/raw "struct foo {};")
user=> (cpp/raw "struct bar : foo {};")

user=> (let [_ (if true (cpp/& cpp/bar) (cpp/& cpp/foo))])
─ analyze/mismatched-if-types ──────────────────────────────────────────────────────────────────────
error: Mismatched 'if' branch types 'bar *' and 'foo *'. Each branch of an 'if' must have the same
       type.

The above if should ideally return a pointer reference of type foo *.

shantanu-sardesai avatar Oct 18 '25 04:10 shantanu-sardesai