skip icon indicating copy to clipboard operation
skip copied to clipboard

`.clipShape(.rect())` type inference fails with a confusing error message

Open dfabulich opened this issue 9 months ago • 1 comments

In https://github.com/dfabulich/skipapp-showcase/tree/clipshape-rect-error-repro there's a commit https://github.com/dfabulich/skipapp-showcase/commit/282d0aabd524e6d3811e662601710ec2ebf5e1f1 that reproduces an error in Skip.

In ShapePlayground.swift, I added code like this:

HStack {
    Text("clipShape")
    Spacer()
    Color.black
        .frame(width: 100, height: 100)
        .clipShape(.rect(topLeadingRadius: 10, bottomLeadingRadius: 20, bottomTrailingRadius: 30, topTrailingRadius: 40))
        .border(.blue)
}

It works correctly if I set SKIP_ZERO = 1 in Showcase.xcconfig, but when I try to compile it with Skip, it fails with a confusing error message:

ShapePlayground.swift:125:134 Argument type mismatch: actual type is 'kotlin.String', but 'skip.ui.Shape' was expected.

I can workaround the issue by replacing .rect like this:

.clipShape(UnevenRoundedRectangle(topLeadingRadius: 10, bottomLeadingRadius: 20, bottomTrailingRadius: 30, topTrailingRadius: 40))

… but the error message is certainly not helping me figure out why this is breaking.

dfabulich avatar Mar 24 '25 21:03 dfabulich

I thought briefly that this might be another example of #375, so I tried working around the issue like this:

.clipShape(.rect(topLeadingRadius: 10.0, bottomLeadingRadius: 20.0, bottomTrailingRadius: 30.0, topTrailingRadius: 40.0))

… but that didn't help at all. I get the same error message.

dfabulich avatar Mar 24 '25 21:03 dfabulich