johnpatrickmorgan / wtfautolayout

The source code for Why The Failure, Auto Layout?
https://www.wtfautolayout.com
MIT License
1.08k stars 22 forks source link

Parse error for constraint multipliers #2

Closed behdaad closed 7 years ago

behdaad commented 7 years ago

Example input:

( "<NSLayoutConstraint:0x167e8dd10 UIImageView:0x167e89f20.centerX == ServiceTypeCarouselItemView:0x167e89d20.centerX>", "<NSLayoutConstraint:0x167e8ddb0 UIImageView:0x167e89f20.width == ServiceTypeCarouselItemView:0x167e89d20.width 0.7>", "= ServiceTypeCarouselItemView:0x167e89d20.leading + 5>", "<NSLayoutConstraint:0x167e8dea0 UILabel:0x167e8a1c0.centerX == UIImageView:0x167e89f20.centerX>", "<NSLayoutConstraint:0x167e8e8b0 UIImageView:0x167e89f20.width == ServiceTypeCarouselItemView:0x167e89d20.width 0.8>" )

Output: UNEXPECTED INPUT: Line 4, Column 117 "<NSLayoutConstraint:0x167e8ddb0 UIImageView:0x167e89f20.width == ServiceTypeCarouselItemView:0x167e89d20.width * 0.7>",


EXPECTED:
'('
whitespace
'+' in +
'-' in -
'>' in >"
johnpatrickmorgan commented 7 years ago

@behdad-keynejad Thanks for raising an issue. This is the first time I've seen the multipliers printed this way, rather than e.g.:

"<NSLayoutConstraint:0x167e8ddb0 UIImageView:0x167e89f20.width == 0.7*ServiceTypeCarouselItemView:0x167e89d20.width>",

See parsing code.

Can I ask what iOS version this was printed with please?

StasanTelnov commented 7 years ago

I have this error too:

(
    "<NSAutoresizingMaskLayoutConstraint:0x181af7c0 AWPProductOnMapView:0x4dbb090.height == 234>",
    "<NSLayoutConstraint:0x181cef70 UIImageView:0x4db3270.width == UIImageView:0x4db3270.height * 0.384615>",
    "<NSLayoutConstraint:0x181d2d20 UIImageView:0x4db3270.width == 85>",
    "<NSLayoutConstraint:0x4dc7b00 UIView:0x4db5710.bottom == UIImageView:0x4db3270.bottom + 25>",
    "<NSLayoutConstraint:0x4dc7bd0 UIImageView:0x4db3270.top == UIView:0x4db5710.top + 2>",
    "<NSLayoutConstraint:0x4dc85a0 AWPProductOnMapView:0x4dbb090.bottom == UIView:0x4db5710.bottom>",
    "<NSLayoutConstraint:0x4dc8630 UIView:0x4db5710.top == AWPProductOnMapView:0x4dbb090.top>"
)

And output:

UNEXPECTED INPUT:
Line 3, Column 97
    "<NSLayoutConstraint:0x181cef70 UIImageView:0x4db3270.width == UIImageView:0x4db3270.height * 0.384615>",
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
EXPECTED:
'('
whitespace
'+' in +
'-' in -
'>' in >"

iOS 10.3.1

johnpatrickmorgan commented 7 years ago

@StasanTelnov Thanks for confirming. I haven't been able to recreate this issue but I will add support for it in the parser. I'm going to assume that if there were a constant too, it would come after. Will update when deployed

johnpatrickmorgan commented 7 years ago

@behdad-keynejad @StasanTelnov This change has now been deployed and your inputs should now be parsed correctly. Thanks for raising this.

johnpatrickmorgan commented 7 years ago

@behdad-keynejad @StasanTelnov Out of interest, are you using Masonry or SnapKit? That might explain why the multipliers are printed differently in your logs.

StasanTelnov commented 7 years ago

@johnpatrickmorgan, yes I using Masonry