Skip to content

Commit eef7be9

Browse files
Fix #9890: Add regression test
1 parent 0520e8f commit eef7be9

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

tests/pos/9890.scala

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
object Test {
2+
import scala.compiletime.ops.int._
3+
4+
trait x
5+
6+
type Range[Min <: Int, Max <: Int] <: Tuple = Min match {
7+
case Max => EmptyTuple
8+
case _ => Min *: Range[Min + 1, Max]
9+
}
10+
11+
type TupleMap[Tup <: Tuple, Bound, F[_ <: Bound]] <: Tuple = Tup match {
12+
case EmptyTuple => EmptyTuple
13+
case h *: t => F[h] *: TupleMap[t, Bound, F]
14+
}
15+
type TupleDedup[Tup <: Tuple, Mask] <: Tuple = Tup match {
16+
case EmptyTuple => EmptyTuple
17+
case h *: t => h match {
18+
case Mask => TupleDedup[t, Mask]
19+
case _ => h *: TupleDedup[t, h | Mask]
20+
}
21+
}
22+
23+
type CoordToPos[r <: Int, c <: Int] = r * 9 + c
24+
type Cell[r <: Int, c <: Int, Board <: Tuple] = Tuple.Elem[Board, CoordToPos[r, c]]
25+
type Col[c <: Int, Board <: Tuple] = TupleMap[Range[0, 9], Int, [r <: Int] =>> Cell[r, c, Board]]
26+
27+
type ColFromPos[Pos <: Int] = Pos % 9
28+
29+
type Sudoku1 = (
30+
x, x, x, x, 1, x, 4, x, 6,
31+
8, x, 1, 6, 2, x, x, x, 9,
32+
x, 3, x, x, x, 9, x, 2, x,
33+
34+
5, x, 9, 1, 3, x, x, 6, x,
35+
x, 6, x, 9, x, 2, x, 4, x,
36+
x, 2, x, x, 6, 7, 8, x, 5,
37+
38+
x, 9, x, 5, x, x, x, 3, x,
39+
3, x, x, x, 4, 6, 9, x, 7,
40+
6, x, 7, x, 9, x, x, x, x,
41+
)
42+
43+
//compiles fine
44+
summon[Col[ColFromPos[0], Sudoku1] =:= (x, 8, x, 5, x, x, x, 3, 6)]
45+
46+
summon[TupleDedup[(x, 8, x, 5, x, x, x, 3, 6), Nothing] =:= (x, 8, 5, 3, 6)]
47+
//but this doesn't
48+
summon[TupleDedup[Col[ColFromPos[0], Sudoku1], Nothing] =:= (x, 8, 5, 3, 6)]
49+
}

0 commit comments

Comments
 (0)