Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1938,9 +1938,11 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
// to
// (a1, ..., aN) => e
val params1 = desugar.patternsToParams(elems)
val matchCheck = scrut.getAttachment(desugar.CheckIrrefutable)
.getOrElse(desugar.MatchCheck.IrrefutablePatDef)
desugared = if params1.hasSameLengthAs(elems)
then cpy.Function(tree)(params1, rhs)
else desugar.makeCaseLambda(cases, desugar.MatchCheck.IrrefutablePatDef, protoFormals.length)
else desugar.makeCaseLambda(cases, matchCheck, protoFormals.length)
case _ =>

if desugared.isEmpty then
Expand Down
12 changes: 12 additions & 0 deletions tests/neg/irrefutable-genfrom.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
object Test:
def one: Unit =
for
// Was already an error as expected
(i, Some(_)) <- List.empty[Int] zip List.empty[Option[String]] // error
do ()

def two: Unit =
for
// Used to be a warning
(i, Some(_)) <- List.empty[Int] lazyZip List.empty[Option[String]] // error
do ()
Loading