Open 05109ee7-7cd9-4cd4-92d0-698e676fc6af opened 7 years ago
I don't think this is a bug with the way type inference is performed, I think the diagnostic is the real issue here. Individually, [B] and [C] can be coerced to [A], but + expects homogeneous arguments which means the system is truly ambiguous. If you want to work around this, you should coerce each argument:
let aa = (b as [A]) + (c as [A])
Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, TypeChecker | |Assignee | None | |Priority | Medium | md5: 3686f0973a3fe6a58b141a14d72ecff4Issue Description:
Type inference fails to resolve the type of this expression even though the result type is given explicitly:
let result: [supertype] = [subtype1] + [subtype2]