skip icon indicating copy to clipboard operation
skip copied to clipboard

Error when exporting enum with an associated type with a default value

Open piercifani opened this issue 1 month ago • 2 comments

The following code:

/// Defines the visual and interactive behavior of a button.
public enum ButtonStyle: Sendable {

  /// Simulates a 3D press with a shadow that changes depth on press.
  /// - Parameter shadowHeight: The height of the shadow.
  case press3D(shadowHeight: Double = 4)
}

Fails with the following error when trying to export:

➜  protocols-errors git:(main) ✗ skip export --project travel-posters-model -d Android/lib/debug/ --debug          
[✓] Check Swift Package (0.15s)
[✓] Getting SDK Path (0.0s)
[✓] Build project travel-posters-model (102.26s)
[✗] Assemble frameworks for TravelPostersModel (25.74s)
[✗] e: file:///Users/piercifani/Desktop/skip-errors/protocols-errors/travel-posters-model/.build/plugins/outputs/travel-posters-model/TravelPostersModel/destination/skipstone/TravelPostersModel/src/main/kotlin/travel/posters/model/ButtonStyle.kt:45:44 Initializer type mismatch: expected 'Double', actual 'Int'.
[✗] Skip 1.6.28 export failed with 2 errors
See https://skip.tools/docs/faq and https://community.skip.tools for help
See output log for error details: /tmp/skip-export-2025-11-09T17:27:33Z.txt
Error: 3 errors

piercifani avatar Nov 09 '25 17:11 piercifani

This is very low priority since you can workaround it specifying case press3D(shadowHeight: Double = 4.0)

piercifani avatar Nov 09 '25 17:11 piercifani

Ah yes, the problem is likely that on the Kotlin side, we can't do type coercion from an integer literal to a Double.

marcprux avatar Nov 09 '25 23:11 marcprux