Skip to content

Commit f0d76ca

Browse files
committed
error for refutable for-generator patterns in 3.4
1 parent 8c602b3 commit f0d76ca

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2771,7 +2771,7 @@ object Parsers {
27712771
atSpan(startOffset(pat), accept(LARROW)) {
27722772
val checkMode =
27732773
if casePat then GenCheckMode.FilterAlways
2774-
else if sourceVersion.isAtLeast(`future`) then GenCheckMode.Check
2774+
else if sourceVersion.isAtLeast(`3.4`) then GenCheckMode.Check
27752775
else if sourceVersion.isAtLeast(`3.2`) then GenCheckMode.CheckAndFilter
27762776
else GenCheckMode.FilterNow // filter on source version < 3.2, for backward compat
27772777
GenFrom(pat, subExpr(), checkMode)

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,13 @@ trait Checking {
923923
|
924924
|If $usage is intentional, this can be communicated by $fix,
925925
|which $addendum.$rewriteMsg"""),
926-
pos, warnFrom = `3.2`, errorFrom = `future`)
926+
pos,
927+
warnFrom = `3.2`,
928+
// we tighten for-comprehension without `case` to error in 3.4,
929+
// but we keep pat-defs as warnings for now ("@unchecked"),
930+
// until we propose an alternative way to assert exhaustivity to the typechecker.
931+
errorFrom = if isPatDef then `future` else `3.4`
932+
)
927933
false
928934
}
929935

0 commit comments

Comments
 (0)