Skip to content

Commit

Permalink
Merge branch 'new-definition-typing' into newQ
Browse files Browse the repository at this point in the history
  • Loading branch information
NeilKleistGao authored Dec 6, 2023
2 parents 00c755c + b11b9cb commit ee8d476
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions shared/src/test/diff/nu/OptionFilter.mls
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
:NewDefs

// FIXME: this looks like a bug about mutually-referential definitions
abstract class Option[out T]: (Some[T] | None) {
virtual fun filter: (p: T -> Bool) -> Option[T]
}
class Some[out T](val value: T) extends Option[T] {
fun filter(p) = if p of value then Some(value) else None
}
module None extends Option[nothing] {
fun filter(_) = None
}
//│ ╔══[ERROR] Type `#Some & {Some#T <: ?T}` does not contain member `Option#T`
//│ ║ l.4: abstract class Option[out T]: (Some[T] | None) {
//│ ╙── ^
//│ ╔══[ERROR] Type `#None` does not contain member `Option#T`
//│ ║ l.4: abstract class Option[out T]: (Some[T] | None) {
//│ ╙── ^
//│ abstract class Option[T]: None | Some[T] {
//│ fun filter: (p: T -> Bool) -> Option[T]
//│ }
//│ class Some[T](value: T) extends Option {
//│ fun filter: (T -> Object) -> (None | Some[T])
//│ }
//│ module None extends Option {
//│ fun filter: anything -> None
//│ }

0 comments on commit ee8d476

Please sign in to comment.