jank
jank copied to clipboard
Support for common types in `if`
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 *.