`.environment(\.font, .custom(...))` type inference fails with a confusing error message
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 3.2k
- Forks
- 106
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 1
Description
In SwiftUI, you can use the .environment() modifier to set a custom default font, like this:
.environment(\.font, .custom("Protest Guerrilla", size: 30.0))
But Skip has a type inference bug in this code: you have to call it with Font.custom() and not with simply .custom(), or it will fail to compile on Android.
I know that type-inference bugs are something I just have to deal with in Skip, but instead of saying, "Cannot infer type for this parameter", I get a really cryptic error message.
To reproduce this bug, I forked the Showcase app https://github.com/dfabulich/skipapp-showcase/tree/environment-font-bug-example and added a one-line commit: https://github.com/dfabulich/skipapp-showcase/commit/4d55295eeccc98e66e33a313b59d27ace864779c
Expected: Build fails with "Cannot infer type for this parameter" error
Actual:
Argument type mismatch: actual type is 'kotlin.Function1<ERROR CLASS: Unknown return lambda parameter type, ERROR CLASS: Unknown return lambda parameter type>', but 'kotlin.String' was expected.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Showcase app branch and its one-line commit reproducing the .environment(\.font, .custom(...)) call. Compare the expected type-inference diagnostic with the actual Kotlin error during the Android build; done means the failure reports "Cannot infer type for this parameter" instead of the cryptic type mismatch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, swift
- Domain
- compilers, mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100