skiptools / skiptools/skip

Bad error message for failed implicit numeric conversion

Open
#375 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

transpilation
Dominant language
Swift
Stars
3.2k
Forks
106
Avg merge
6d 13h
Merged PRs (30d)
1

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure using the linked skipapp-showcase commit and the expression at Sources/Showcase/TabViewPlayground.swift:113, with SKIP_ZERO unset. Start by tracing how the compiler handles the failed implicit numeric conversion and emits the reported candidates and unresolved Compose diagnostics. Done means the expression either compiles as expected or produces a direct, actionable diagnostic explaining the required explicit conversion.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.