Skip to content

Conversation

@xedin
Copy link
Contributor

@xedin xedin commented Aug 20, 2018

…ts too eagerly

Avoid claiming un-labeled defaulted parameters
by out-of-order un-labeled arguments or parts
of variadic argument sequence, because that might
be incorrect:

func foo(_ a: Int, _ b: Int = 0, c: Int = 0, _ d: Int) {}
foo(1, c: 2, 3) // -> `3` will be claimed as '_ b:'.

Resolves: rdar://problem/43525641

@xedin xedin requested review from harlanhaskins and rudkx August 20, 2018 22:53
@xedin
Copy link
Contributor Author

xedin commented Aug 20, 2018

@swift-ci please smoke test

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad this one was improved!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is unfortunate, but livable...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, because 2 is no longer re-ordered with a: 1, which I think is a more correct behavior.

@rudkx
Copy link
Contributor

rudkx commented Aug 20, 2018

@xedin Can you update the commit message to make it clear whether the example you're giving is the old behavior or the new behavior? For example you could provide the example and an explanation of what happened before, versus after your change.

@xedin
Copy link
Contributor Author

xedin commented Aug 20, 2018

@rudkx Sure! It’s currently an error, but I fixed it to type-check...

…ts too eagerly

Avoid claiming un-labeled defaulted parameters
by out-of-order un-labeled arguments or parts
of variadic argument sequence, because that might
be incorrect.

The following example is supposed to type-check
correctly but without these changes produces
`missing argument for parameter swiftlang#4 in call`
error, because `3` will be claimed as '_ b:':

```swift
func foo(_ a: Int, _ b: Int = 0, c: Int = 0, _ d: Int) {}
foo(1, c: 2, 3)
```

Resolves: rdar://problem/43525641
@xedin
Copy link
Contributor Author

xedin commented Aug 21, 2018

@rudkx How does the message look like now?

@xedin
Copy link
Contributor Author

xedin commented Aug 21, 2018

@swift-ci please smoke test

@xedin
Copy link
Contributor Author

xedin commented Aug 21, 2018

@swift-ci please test source compatibility

@xedin xedin merged commit 811e979 into swiftlang:master Aug 21, 2018
@harlanhaskins
Copy link
Contributor

Thanks, @xedin!

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