Skip to content

regression: ensuring on ??? #5249

@olhotak

Description

@olhotak

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions