Skip to content

Commit 245a519

Browse files
committed
Status quo clashing of given names in for desugar
1 parent b20b338 commit 245a519

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

tests/neg/i23119.check

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- [E161] Naming Error: tests/neg/i23119.scala:7:4 ---------------------------------------------------------------------
2+
7 | given Option[List[Int]] = Some(List(x)) // error
3+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+
| given_Option_List is already defined as given instance given_Option_List
5+
|
6+
| Note that overloaded methods must all be defined in the same group of toplevel definitions

tests/neg/i23119.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
@main def test = println:
3+
for x <- 1 to 2
4+
// works with explicit name
5+
//ols @ given Option[List[String]] = Some(List(x.toString))
6+
given Option[List[String]] = Some(List(x.toString))
7+
given Option[List[Int]] = Some(List(x)) // error
8+
yield summon[Option[List[String]]].map(ss => ss.corresponds(given_Option_List.get)((a, b) => a == b.toString))
9+
10+
// The naming clash is noticed when defining local values for "packaging":
11+
// given_Option_List is already defined as given instance given_Option_List
12+
// Previously the naming clash was noticed when extracting values in the map or do function:
13+
// duplicate pattern variable: given_Option_List

0 commit comments

Comments
 (0)