We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2ba368d commit be27e79Copy full SHA for be27e79
tests/pos/match-type-printf.scala
@@ -0,0 +1,19 @@
1
+import scala.compiletime.ops.int.+
2
+import scala.compiletime.ops.string.{CharAt, Length, Substring}
3
+import scala.Tuple.*
4
+
5
+type ArgTypes[S <: String] <: Tuple = S match
6
+ case "" => EmptyTuple
7
+ case _ =>
8
+ CharAt[S, 0] match
9
+ case '%' =>
10
+ CharAt[S, 1] match
11
+ case 'd' => Int *: ArgTypes[Substring[S, 2, Length[S]]]
12
+ case 's' => String *: ArgTypes[Substring[S, 2, Length[S]]]
13
+ case _ => ArgTypes[Substring[S, 1, Length[S]]]
14
15
+def printf(s: String)(t: ArgTypes[s.type]): Unit = ()
16
17
+def test() =
18
+ printf("%s is %d")(("Ada", 36)) // works in Scala 3.2.0, 3.3.0 and 3.4.0
19
+ printf("%s is lorem %d")(("Ada", 36)) // works in Scala 3.4.0 but fails in Scala 3.2.0 and 3.3.0
0 commit comments