monadless / monadless

Syntactic sugar for monad composition in Scala
http://monadless.io
Apache License 2.0
279 stars 17 forks source link

compile failure: scala-js #5

Open aappddeevv opened 6 years ago

aappddeevv commented 6 years ago

Version: (e.g. 0.0.1-SNAPSHOT) monadless: 0.13 scala-js: 1.0.0-RC2, up from 0.6.21 where it worked fine.

Expected behavior

Compile should work.

Actual behavior

Can't typecheck the monadless transformation.

Steps to reproduce the behavior

scala-js non-native JS class that uses UndefOr

class TestJS (
  val name: js.UndefOr[String] = js.undefined
) extends js.Object

code that causes the issue:

lift {
  new TestJS(name="blah")
}

Error:

importdataactions.scala:120:20: Can't typecheck the monadless transformation. Please file a bug report with this error and your `Monadless` instance. 
[error] Failure: $bar is not an enclosing class
[error] Tree: Task.apply(new TestJS(js.this.$bar.from[String, String, Unit]("blah")($bar.this.Evidence.left[String, String, Unit]($bar.this.Evidence.base[String]))))
[error]       val x = lift {
[error]                    ^

Note there is no monad in there yet, just a constant. However, in the full code I need to do this inside the lift in order to call my monad, fs2.Task.

Workaround

None identified.

fwbrasil commented 6 years ago

I couldn't reproduce it. Also, the error message seems to be for another tree, not the example one. Could you try to reproduce it in isolation using scastie? Here's an example snippet with monadless and scalajs configured: https://scastie.scala-lang.org/aAKsqOXlRq6rEPttSVrsvA

aappddeevv commented 6 years ago

Here's a project that demonstrates the issue: https://github.com/aappddeevv/scalajs-monadless.git

It worked find under 0.6.x scala-js.

aappddeevv commented 6 years ago

@sjrd mentioned that $bar is the mangled name of the Undef type, which uses a pseudo-union e.g. Undef = A | js.undefined.