Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solves dotc assertion error on (non-sensical?) parameter type. #13769 #13830

Merged
merged 1 commit into from Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Expand Up @@ -442,6 +442,9 @@ object Parsers {
def convertToParam(tree: Tree, mods: Modifiers, expected: String = "formal parameter"): ValDef = tree match {
case id @ Ident(name) =>
makeParameter(name.asTermName, TypeTree(), mods, isBackquoted = isBackquoted(id)).withSpan(tree.span)
case Typed(_, tpt: TypeBoundsTree) =>
syntaxError(s"not a legal $expected", tree.span)
makeParameter(nme.ERROR, tree, mods)
case Typed(id @ Ident(name), tpt) =>
makeParameter(name.asTermName, tpt, mods, isBackquoted = isBackquoted(id)).withSpan(tree.span)
case Typed(Splice(Ident(name)), tpt) =>
Expand Down
10 changes: 10 additions & 0 deletions tests/neg/i13769.check
@@ -0,0 +1,10 @@
-- Error: tests/neg/i13769.scala:2:18 ----------------------------------------------------------------------------------
2 |val te = tup.map((x: _ <: Int) => List(x)) // error // error
| ^^^^^^^^^^^
| not a legal formal parameter
-- [E006] Not Found Error: tests/neg/i13769.scala:2:39 -----------------------------------------------------------------
2 |val te = tup.map((x: _ <: Int) => List(x)) // error // error
| ^
| Not found: x

longer explanation available when compiling with `-explain`
2 changes: 2 additions & 0 deletions tests/neg/i13769.scala
@@ -0,0 +1,2 @@
val tup = (1, "s")
val te = tup.map((x: _ <: Int) => List(x)) // error // error