tenderowls / moorka

ABANDONED
21 stars 5 forks source link

Felix silently ignores invalid types, when calling `get` method #87

Open vsuharnikov opened 8 years ago

vsuharnikov commented 8 years ago

For example, we have a JS object:

window.foo = {
  id: 1
  name: "foo"
};

If we try to get "id" as String (it actually is Int):

// ref points to foo
ref.get[String]("id") onComplete {
  case x => println(x)
}

nothing will happen. It seems that the error is in "unpackArg" method:

def unpackArg[A](arg: Any): A = arg match {
  // …
  case otherwise ⇒
    val r = platformDependentUnpack(otherwise)
    r.asInstanceOf[A] // Here
}

unpackArg should return Try[A] and, namely, Failure, if it can't cast the value to a type A.

But i can't to fix it and check a solution, because the current develop branch is simply not working. So, i've created an issue.