Skip to content

Commit 2904561

Browse files
test: add in a regression test for #11118 (#17495)
This adds in a regression test showing that just like in Scala 2 a user sees a warning about how the right hand side doesn't match the type of the left. closes #11118
2 parents b39d38e + 720bff8 commit 2904561

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

tests/neg/i11118.check

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- Warning: tests/neg/i11118.scala:2:12 --------------------------------------------------------------------------------
2+
2 |val (a,b) = (1,2,3) // error // warning
3+
| ^^^^^^^
4+
| pattern's type (Any, Any) does not match the right hand side expression's type (Int, Int, Int)
5+
|
6+
| If the narrowing is intentional, this can be communicated by adding `: @unchecked` after the expression,
7+
| which may result in a MatchError at runtime.
8+
| This patch can be rewritten automatically under -rewrite -source 3.2-migration.
9+
-- Error: tests/neg/i11118.scala:2:4 -----------------------------------------------------------------------------------
10+
2 |val (a,b) = (1,2,3) // error // warning
11+
| ^
12+
| this case is unreachable since type (Int, Int, Int) is not a subclass of class Tuple2

tests/neg/i11118.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// https://github.com/lampepfl/dotty/issues/11118
2+
val (a,b) = (1,2,3) // error // warning

0 commit comments

Comments
 (0)