-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update check-files and error annotations
The diff in neg/10349.scala is quite interesting. With a few intermediate values: ```scala type First[X] = X match case Map[_, v] => First[Option[v]] def first[X](x: X): First[X] = x match case x: Map[k, v] => val hdOpt: Option[v] = x.values.headOption first(hdOpt): First[Option[v]] // error only before changes ``` This now type-checks but will fail at runtime because of the in-exhaustivity of the match expression. Perhaps we should add some additional condition in `isMatchTypeShaped` to account for this, or at least emit a warning ?
- Loading branch information
1 parent
69e14db
commit 646fea8
Showing
7 changed files
with
102 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,10 @@ | ||
import scala.quoted._, scala.deriving.* // error | ||
// ^ | ||
// Match type reduction failed since selector ((2 : Int), quoted.Expr[(3 : Int)]) | ||
// matches none of the cases | ||
// | ||
// case quoted.Expr[x] *: t => x *: scala.Tuple.InverseMap[t, quoted.Expr] | ||
// case EmptyTuple => EmptyTuple | ||
|
||
inline def mcr: Any = ${mcrImpl} // error | ||
// ^ | ||
// Match type reduction failed since selector ((2 : Int), quoted.Expr[(3 : Int)]) | ||
// matches none of the cases | ||
// | ||
// case quoted.Expr[x] *: t => x *: scala.Tuple.InverseMap[t, quoted.Expr] | ||
// case EmptyTuple => EmptyTuple | ||
|
||
def mcrImpl(using ctx: Quotes): Expr[Any] = { // error // error | ||
//^ | ||
// Match type reduction failed since selector ((2 : Int), quoted.Expr[(3 : Int)]) | ||
// matches none of the cases | ||
// | ||
// case quoted.Expr[x] *: t => x *: scala.Tuple.InverseMap[t, quoted.Expr] | ||
// case EmptyTuple => EmptyTuple | ||
|
||
// ^ | ||
// Match type reduction failed since selector ((2 : Int), quoted.Expr[(3 : Int)]) | ||
// matches none of the cases | ||
// | ||
// case quoted.Expr[x] *: t => x *: scala.Tuple.InverseMap[t, quoted.Expr] | ||
// case EmptyTuple => EmptyTuple | ||
import scala.quoted._, scala.deriving.* | ||
|
||
inline def mcr: Any = ${mcrImpl} | ||
def mcrImpl(using ctx: Quotes): Expr[Any] = { | ||
val tpl: (Expr[1], Expr[2], Expr[3]) = ('{1}, '{2}, '{3}) | ||
'{val res: (1, 3, 3) = ${Expr.ofTuple(tpl)}; res} // error | ||
// ^^^^^^^^^^^^^^^^^ | ||
// Found: quoted.Expr[(1 : Int) *: (2 : Int) *: (3 : Int) *: EmptyTuple] | ||
// Required: quoted.Expr[((1 : Int), (3 : Int), (3 : Int))] | ||
|
||
val tpl2: (Expr[1], 2, Expr[3]) = ('{1}, 2, '{3}) | ||
'{val res = ${Expr.ofTuple(tpl2)}; res} // error // error // error // error | ||
// ^ | ||
// Cannot prove that (quoted.Expr[(1 : Int)], (2 : Int), quoted.Expr[(3 : Int)]) =:= scala.Tuple.Map[ | ||
// scala.Tuple.InverseMap[ | ||
// (quoted.Expr[(1 : Int)], (2 : Int), quoted.Expr[(3 : Int)]) | ||
// , quoted.Expr] | ||
// , quoted.Expr]. | ||
|
||
// ^ | ||
// Match type reduction failed since selector ((2 : Int), quoted.Expr[(3 : Int)]) | ||
// matches none of the cases | ||
// | ||
// case quoted.Expr[x] *: t => x *: scala.Tuple.InverseMap[t, quoted.Expr] | ||
// case EmptyTuple => EmptyTuple | ||
|
||
// ^ | ||
// Cyclic reference involving val res | ||
|
||
// ^ | ||
// Match type reduction failed since selector ((2 : Int), quoted.Expr[(3 : Int)]) | ||
// matches none of the cases | ||
// | ||
// case quoted.Expr[x] *: t => x *: scala.Tuple.InverseMap[t, quoted.Expr] | ||
// case EmptyTuple => EmptyTuple | ||
'{val res = ${Expr.ofTuple(tpl2)}; res} // error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters