Skip to content

Conversation

@jayrhynas
Copy link

@jayrhynas jayrhynas commented Apr 27, 2023

Splits Edge type into EdgeXAxis and EdgeYAxis types
Provides compile-time safety to ensure that invalid constraints are not created between edges on different axes.

Before this change, the following code would compile but raise an exception at runtime:

constrain(view1, view2) { view1, view2 in
  view1.top == view2.left
}
Uncaught Exception at File.swift:2: Constraint improperly relates anchors of incompatible types: <NSLayoutConstraint:0x600002e9ccd0 UIView:0x133d0f610.top == UIView:0x133d0f090.left   (active)> (NSInvalidLayoutConstraintException)

Now, this will raise a compile time error:

Binary operator '==' cannot be applied to operands of type 'EdgeYAxis' and 'EdgeXAxis'

Provides compile-time safety to ensure that invalid constraints are not created between edges on different axes
@jayrhynas
Copy link
Author

jayrhynas commented Apr 27, 2023

This should be merged after #352 if both are going to be merged. jayrhynas/Cartography:de0452d updates the offset operator to compile with this PR.

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.

1 participant