Skip to content
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

Priority Operator Error #241

Closed
JohnCoates opened this issue Oct 1, 2016 · 5 comments
Closed

Priority Operator Error #241

JohnCoates opened this issue Oct 1, 2016 · 5 comments

Comments

@JohnCoates
Copy link
Contributor

The priority example in the Readme fails to compile on Swift 3.0

var constraint: NSLayoutConstraint!
constrain(view) { (view: LayoutProxy) in
    constraint = view.width == 200 ~ 100
}            
expect(constraint.priority).to(equal(100))

Errors:

Cartography/CartographyTests/PrioritySpec.swift:22:28: error: adjacent operators are in unordered precedence groups 'AssignmentPrecedence' and 'CarthographyPriorityPrecedence'
                constraint = view.width == 200 ~ 100
                           ^                   ~
Cartography/CartographyTests/PrioritySpec.swift:22:48: error: binary operator '~' cannot be applied to operands of type '()' and 'Int'
                constraint = view.width == 200 ~ 100
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~
Cartography/CartographyTests/PrioritySpec.swift:22:48: note: overloads for '~' exist with these partially matching parameter lists: (NSLayoutConstraint, LayoutPriority), ([NSLayoutConstraint], LayoutPriority)
                constraint = view.width == 200 ~ 100
@JohnCoates
Copy link
Contributor Author

adding higherThan: AssignmentPrecedence to precedencegroup CarthographyPriorityPrecedence fixes the first error.

Not sure what the best fix for the second & third errors are, but wrapping the priority in LayoutPriority() makes it compile at least.
constraint = view.width == 200 ~ LayoutPriority(100)

@orta
Copy link
Collaborator

orta commented Oct 2, 2016

Yeah, the implicit LayoutPriority was something we couldn't figure out when porting to Swift 3 - I'd love for you to dig in here and see if you can figure that one out?

@JohnCoates
Copy link
Contributor Author

Okay, sure I'll have a go at it

@JohnCoates
Copy link
Contributor Author

JohnCoates commented Oct 3, 2016

I believe this is a bug with the compiler.
I've filed a Swift bug report and a radar about this issue. The more radars that get filed, the more traction the bug gets, so I recommend filing one also.

@orta
Copy link
Collaborator

orta commented Oct 3, 2016

Perfect! Shipped as 1.0.1 - thanks!

@orta orta closed this as completed Oct 3, 2016
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

No branches or pull requests

2 participants