Skip to content

[stdlib] Rearrange + on RangeReplaceableCollection/Sequence once again #13736

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

Merged
merged 1 commit into from
Jan 6, 2018

Conversation

moiseev
Copy link
Contributor

@moiseev moiseev commented Jan 4, 2018

Based on the discssion here #13697

@moiseev moiseev changed the title [stdlib] Rearrange + on RangeReplaceableCollection/Sequence once again Based on the discssion here https://github.com/apple/swift/pull/13697 [stdlib] Rearrange + on RangeReplaceableCollection/Sequence once again Jan 4, 2018
@moiseev
Copy link
Contributor Author

moiseev commented Jan 4, 2018

@swift-ci Please smoke test

@moiseev
Copy link
Contributor Author

moiseev commented Jan 4, 2018

/cc @jrose-apple and @xedin

@jrose-apple
Copy link
Contributor

jrose-apple commented Jan 4, 2018

I'm still confused as to why we can't put the other one on RRC too, but sure.

(i.e. if there's an ambiguity error, that'd be a type-checker bug, right?)

@moiseev
Copy link
Contributor Author

moiseev commented Jan 4, 2018

@jrose-apple The code that gets ambiguous is this: [first] + rest. Where rest is an Array. But, [first] is not strictly an array, it can also be a Set, which is not a RRC. Therefore, I think, ambiguity is between "set as Sequence + array as RRC" and "array as RRC + array as RRC".

@jrose-apple
Copy link
Contributor

Hm. How is rest + [last] not equally ambiguous, then?

We won't pull the type "Set" out of thin air, and we should still default to Array as the default array literal type. So I'm not sure I buy this explanation.

What does -Xfrontend -debug-constraints say? cc @xedin

@moiseev
Copy link
Contributor Author

moiseev commented Jan 5, 2018

Hm. How is rest + [last] not equally ambiguous, then?

Maybe it is, but we don't have expression like this in the codebase.

@xedin
Copy link
Contributor

xedin commented Jan 5, 2018

@jrose-apple Looked it for a bit this morning, the other way around is also ambiguous in stdlib :)

swift/stdlib/public/core/Codable.swift:2686:78: error: ambiguous use of operator '+'
        let context = DecodingError.Context(codingPath: container.codingPath + [key],
                                                                             ^

@moiseev
Copy link
Contributor Author

moiseev commented Jan 6, 2018

After having discussed with @xedin we decided to merge this PR and then, when the ranking bug is fixed, move the last + overload from Sequence to RangeReplaceableCollection.

@moiseev moiseev merged commit 5a01af3 into swiftlang:master Jan 6, 2018
@moiseev moiseev deleted the rrc-ops branch January 6, 2018 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants