File tree 5 files changed +38
-2
lines changed
compiler/src/dotty/tools/dotc/transform
5 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -65,15 +65,15 @@ object Splicer {
65
65
EmptyTree
66
66
case ex : StopInterpretation =>
67
67
report.error(ex.msg, ex.pos)
68
- EmptyTree
68
+ ref(defn. Predef_undefined ).withType( ErrorType (ex.msg))
69
69
case NonFatal (ex) =>
70
70
val msg =
71
71
s """ Failed to evaluate macro.
72
72
| Caused by ${ex.getClass}: ${if (ex.getMessage == null ) " " else ex.getMessage}
73
73
| ${ex.getStackTrace.takeWhile(_.getClassName != " dotty.tools.dotc.transform.Splicer$" ).drop(1 ).mkString(" \n " )}
74
74
""" .stripMargin
75
75
report.error(msg, pos)
76
- EmptyTree
76
+ ref(defn. Predef_undefined ).withType( ErrorType (msg))
77
77
}
78
78
}
79
79
Original file line number Diff line number Diff line change
1
+ import scala .quoted ._
2
+
3
+ def f () = ()
4
+
5
+ def triggerStackOverflow (n : Int ): Expr [Double ] = {
6
+ val r = triggerStackOverflow(n - 1 )
7
+ f()
8
+ r
9
+ }
10
+
11
+ inline def loop (inline prog : Double ): Double = $ {impl(' prog )}
12
+
13
+ def impl (prog : Expr [Double ])(using QuoteContext ) : Expr [Double ] =
14
+ try {
15
+ triggerStackOverflow(0 )
16
+ } catch {
17
+ case e =>
18
+ qctx.tasty.error(e.getMessage, prog.unseal.pos)
19
+ ' { 42.0 }
20
+ }
Original file line number Diff line number Diff line change
1
+ def test : Unit = loop(4 ) // error
Original file line number Diff line number Diff line change
1
+ import scala .quoted ._
2
+
3
+ def f () = ()
4
+
5
+ def triggerStackOverflow (n : Int ): Expr [Double ] = {
6
+ val r = triggerStackOverflow(n - 1 )
7
+ f()
8
+ r
9
+ }
10
+
11
+ inline def loop (inline prog : Double ): Double = $ {impl(' prog )}
12
+
13
+ def impl (prog : Expr [Double ])(using QuoteContext ) : Expr [Double ] =
14
+ triggerStackOverflow(0 )
Original file line number Diff line number Diff line change
1
+ def test : Unit = loop(4 ) // error
You can’t perform that action at this time.
0 commit comments