Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions library/src/scala/NamedTuple.scala
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ object NamedTuple:
type From[T] <: AnyNamedTuple

/** The type of the empty named tuple */
type Empty = EmptyTuple.type
type Empty = NamedTuple[EmptyTuple, EmptyTuple]

/** The empty named tuple */
val Empty: Empty = EmptyTuple.asInstanceOf[Empty]
val Empty: Empty = EmptyTuple

end NamedTuple

Expand Down
2 changes: 2 additions & 0 deletions tests/run/named-tuples.check
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ Bob is younger than Lucy
Bill is younger than Lucy
(((Lausanne,Pully),Preverenges),((1003,1009),1028))
118
()
(name,age)
8 changes: 8 additions & 0 deletions tests/run/named-tuples.scala
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ val _: CombinedInfo = bob ++ addr
val totalAge = persons.mapReduce(reducer)
println(totalAge)

inline def namesOf[T <: AnyNamedTuple](t: T): Names[T] = compiletime.constValueTuple[Names[T]]
val namesEmpty = namesOf(NamedTuple.Empty)
val namesBob = namesOf(bob)
val namesEmpty2: EmptyTuple = namesEmpty
val namesBob2: ("name", "age") = namesBob
println(namesEmpty)
println(namesBob)

// testing conversions
object Conv:

Expand Down