File tree 3 files changed +17
-0
lines changed
compiler/src/dotty/tools/dotc/staging
3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -214,6 +214,10 @@ class CrossStageSafety extends TreeMapWithStages {
214
214
" \n\n " +
215
215
" Hint: Staged references to inline definition in quotes are only inlined after the quote is spliced into level 0 code by a macro. " +
216
216
" Try moving this inline definition in a statically accessible location such as an object (this definition can be private)."
217
+ else if level > 0 && sym.info.derivesFrom(defn.QuotesClass ) then
218
+ s """ \n
219
+ |Hint: Nested quote needs a local context defined at level $level.
220
+ |One way to introduce this context is to give the outer quote the type `Expr[Quotes ?=> Expr[T]]`. """ .stripMargin
217
221
else " "
218
222
report.error(
219
223
em """ access to $symStr from wrong staging level:
Original file line number Diff line number Diff line change
1
+ -- Error: tests/neg-macros/i17338.scala:4:5 ----------------------------------------------------------------------------
2
+ 4 | '{ '{ 1 } } // error
3
+ | ^
4
+ | access to parameter quotes from wrong staging level:
5
+ | - the definition is at level 0,
6
+ | - but the access is at level 1.
7
+ |
8
+ | Hint: Nested quote needs a local context defined at level 1.
9
+ | One way to introduce this context is to give the outer quote the type `Expr[Quotes ?=> Expr[T]]`.
Original file line number Diff line number Diff line change
1
+ import scala .quoted .*
2
+
3
+ def test (using quotes : Quotes ): Expr [Expr [Int ]] =
4
+ ' { ' { 1 } } // error
You can’t perform that action at this time.
0 commit comments