Skip to content

Commit 0eb7e61

Browse files
authored
Merge pull request #13830 from SergioDSR/i13769
solves dotc assertion error on (non-sensical?) parameter type. #13769
2 parents 5eef0c6 + 0f5029d commit 0eb7e61

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,9 @@ object Parsers {
442442
def convertToParam(tree: Tree, mods: Modifiers, expected: String = "formal parameter"): ValDef = tree match {
443443
case id @ Ident(name) =>
444444
makeParameter(name.asTermName, TypeTree(), mods, isBackquoted = isBackquoted(id)).withSpan(tree.span)
445+
case Typed(_, tpt: TypeBoundsTree) =>
446+
syntaxError(s"not a legal $expected", tree.span)
447+
makeParameter(nme.ERROR, tree, mods)
445448
case Typed(id @ Ident(name), tpt) =>
446449
makeParameter(name.asTermName, tpt, mods, isBackquoted = isBackquoted(id)).withSpan(tree.span)
447450
case Typed(Splice(Ident(name)), tpt) =>

tests/neg/i13769.check

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- Error: tests/neg/i13769.scala:2:18 ----------------------------------------------------------------------------------
2+
2 |val te = tup.map((x: _ <: Int) => List(x)) // error // error
3+
| ^^^^^^^^^^^
4+
| not a legal formal parameter
5+
-- [E006] Not Found Error: tests/neg/i13769.scala:2:39 -----------------------------------------------------------------
6+
2 |val te = tup.map((x: _ <: Int) => List(x)) // error // error
7+
| ^
8+
| Not found: x
9+
10+
longer explanation available when compiling with `-explain`

tests/neg/i13769.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
val tup = (1, "s")
2+
val te = tup.map((x: _ <: Int) => List(x)) // error // error

0 commit comments

Comments
 (0)