New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ambiguous initializers #125
Comments
Although I haven't yet been able to reduce it to a reproducible example, the following code also fails:
In this case, the trigger appears to be
|
Interesting! We have two overloads for these, one for sequences where I think the candidate that requires inferring tuple labels ought to be considered less favored than the one where labels line up, so this is arguably a compiler issue -- cc @hborla what do you think? |
My naive expectation was that the labels are mostly sugar and a distinction between them is unnecessary; though I was surprised the compiler even allowed overloading method signatures where labels are the only distinguishing feature. |
I wrote up the issue in https://bugs.swift.org/browse/SR-15539. While the type checker problem is being investigated, we can use the non-public, underscored The client-level workaround is to move the dictionary literal into its own variable, as you have shown above. This eliminates the type inference case that triggers the issue. |
This is now fixed on the release/1.0 branch. (Merge to main will happen after 1.0.3 is tagged.) |
Duplicate initializers for
OrderedDictionary
cause ambiguity in the compiler when it tries to resolve an initializer, however only under certain circumstances. I'm not 100% certain about what the scope of the issue is, but have included sample code for a data point on where the issue is reproduced.The issue also reproduces in other scenarios which do not look like the included sample (in more complex projects).
Competing initializers:
Information
Checklist
main
branch of this package.Steps to Reproduce
Expected behavior
Notice that
dict1
initialization compiles fine. I expectdict2
initialization to compile fine as well.Actual behavior
dict2
initialization fails, error:The text was updated successfully, but these errors were encountered: