skip icon indicating copy to clipboard operation
skip copied to clipboard

Bad error message for failed implicit numeric conversion

Open dfabulich opened this issue 9 months ago • 1 comments

In https://github.com/dfabulich/skipapp-showcase/tree/bad-error-failed-implicit-numeric-conversion I pushed a commit https://github.com/dfabulich/skipapp-showcase/commit/9c5bb0f35410f372604eb0b4c4ffe60d4481828b

That commit includes a line of idiomatic Swift that doesn't compile correctly in Skip:

https://github.com/dfabulich/skipapp-showcase/blob/9c5bb0f35410f372604eb0b4c4ffe60d4481828b/Sources/Showcase/TabViewPlayground.swift#L113

.aspectRatio(3/2, contentMode: .fill)

This code works just fine if you set SKIP_ZERO = 1, but the Skip compiler is confused by the expression 3/2. aspectRatio expects a CGFloat; it works fine if you write .aspectRatio(3.0/2.0, contentMode: .fill), dividing one CGFloat by another CGFloat to get a CGFloat.

So, that's a bummer, but what's really a bummer is the error message, which sent me on an hours-long wild-goose chase today.

/Users/dfabulich/git/skipapp-showcase/Sources/Showcase/TabViewPlayground.swift:113:48 None of the following candidates is applicable: /Users/dfabulich/git/skipapp-showcase/Sources/Showcase/TabViewPlayground.swift:113:48 Unresolved reference 'Compose'.

That's an extremely unhelpful error message.

Ideally, it would "just work" to pass 3/2 as a synonym for 1.5, but, if it doesn't, and the code needs me to do explicit casting, then I wish the compiler would have just said so.

dfabulich avatar Mar 19 '25 23:03 dfabulich

Sorry about that. The lack of automatic integer/floating-point conversions is indeed a pain point. We've made some improvements in the past with diagnostics, but this clearly is a case that we should try to identify better.

marcprux avatar Mar 19 '25 23:03 marcprux