You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My use case is to give students a method with an empty body and a postcondition, and to ask them to complete the body so it satisfies the postcondition:
object test {
def m(x: Int): Int = {
???
} ensuring(ans => ans == x)
}
This compiles with Dotty 0.7.0 but Dotty master gives:
-- [E008] Member Not Found Error: inferEnsuring.scala:4:5 ----------------------
2 | def m(x: Int): Int = {
3 | ???
| ^
| value `ensuring` is not a member of Nothing
one error found
Since ensuring is a member of Int and since Nothing <: Int, ensuring should also be a member of Nothing.
Although the member is injected by an implicit conversion to Ensuring, the same reasoning applies: the implicit conversion applies to every subtype of Any, and Nothing <: Any.
The text was updated successfully, but these errors were encountered:
Since ensuring is a member of Int and since Nothing <: Int, ensuring should also be a member of Nothing.
This is not the case for Scala when it is related to Null, Nothing.
scala>deff(x: Nothing):Int= x +3
<console>:11:error: value + is not a member of Nothingdeff(x: Nothing):Int= x +3^
scala>deff(x: Null):Int= x +3
<console>:11:error: value + is not a member of Nulldeff(x: Null):Int= x +3^
And in some cases GADT bounds:
caseclassOne[T](fst: T)
objectTest {
defbad[T](e: One[T])(x: T):Int= e match {
casefoo: One[Int] =>
x +4
}
}
/cc: @AleksanderBG The code above compiles in Scalac, but not in Dotty.
My use case is to give students a method with an empty body and a postcondition, and to ask them to complete the body so it satisfies the postcondition:
This compiles with Dotty 0.7.0 but Dotty master gives:
Since
ensuring
is a member ofInt
and sinceNothing <: Int
,ensuring
should also be a member ofNothing
.Although the member is injected by an implicit conversion to
Ensuring
, the same reasoning applies: the implicit conversion applies to every subtype ofAny
, andNothing <: Any
.The text was updated successfully, but these errors were encountered: