getkyo / kyo

Toolkit for Scala Development
https://getkyo.io
Apache License 2.0
558 stars 46 forks source link

Scala Native crash for Aspect #845

Open fwbrasil opened 1 week ago

fwbrasil commented 1 week ago

Scala Native is crashing after https://github.com/getkyo/kyo/pull/839. I had the same issue in https://github.com/getkyo/kyo/pull/843 after adding an aspect to Parse.

[error] /home/runner/work/kyo/kyo/kyo-prelude/native/target/scala-3.5.2/native-test/generated/1a0c1.ll:585314:52: error: '@_SM11kyo.Aspect$D15init$$anonfun$1L16java.lang.ObjectL15scala.Function1L16java.lang.ObjectEpT11kyo.Aspect$' defined with type 'i8* (i8*, i8*)*' but expected 'i8* (i8*)*'
[error]   %_4000001 = call dereferenceable_or_null(16) i8* @"_SM11kyo.Aspect$D15init$$anonfun$1L16java.lang.ObjectL15scala.Function1L16java.lang.ObjectEpT11kyo.Aspect$"(i8* dereferenceable_or_null(16) %_2)
[error]                                                    ^
[error] 1 error generated.
[info] Compiling to native code (5815 ms)
[info] Total (17149 ms)
[error] Failed to compile /home/runner/work/kyo/kyo/kyo-prelude/native/target/scala-3.5.2/native-test/generated/1a0c1.ll
[error] (kyo-preludeNative / Test / nativeLink) Failed to compile /home/runner/work/kyo/kyo/kyo-prelude/native/target/scala-3.5.2/native-test/generated/1a0c1.ll

It seems an issue with the new Cut encoded as a generic function:

type Cut[I[_], O[_], S] = [C] => (I[C], I[C] => O[C] < S) => O[C] < S

To reproduce:

mv kyo-prelude/jvm/src/test/scala/kyo/AspectTest.scala kyo-prelude/shared/src/test/scala/kyo/AspectTest.scala
mv kyo-prelude/jvm/src/test/scala/kyo/ParseTest.scala kyo-prelude/shared/src/test/scala/kyo/ParseTest.scala
fwbrasil commented 1 week ago

Issue is fixed in Scala Native (https://github.com/scala-native/scala-native/issues/4082) but I'll keep this ticket open so we can move the files back once there's a release with the fix.