Skip to content

Commit 31b25e0

Browse files
committed
Add macro annotation ill-abort test
1 parent d361e18 commit 31b25e0

File tree

6 files changed

+18
-3
lines changed

6 files changed

+18
-3
lines changed

compiler/src/dotty/tools/dotc/transform/MacroAnnotations.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class MacroAnnotations(thisPhase: DenotTransformer):
6666
ex0.getCause match
6767
case ex: scala.quoted.runtime.StopMacroExpansion =>
6868
if !ctx.reporter.hasErrors then
69-
report.error("Macro expansion was aborted by the macro without any errors reported. Macros should issue errors to end-users to facilitate debugging when aborting a macro expansion.", annot.tree)
69+
report.error("Macro expansion was aborted by the macro without any errors reported. Macros should issue errors to end-users when aborting a macro expansion with StopMacroExpansion.", annot.tree)
7070
List(tree)
7171
case Interpreter.MissingClassDefinedInCurrentRun(sym) =>
7272
Interpreter.suspendOnMissing(sym, annot.tree)

compiler/src/dotty/tools/dotc/transform/Splicer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ object Splicer {
6969
throw ex
7070
case ex: scala.quoted.runtime.StopMacroExpansion =>
7171
if !ctx.reporter.hasErrors then
72-
report.error("Macro expansion was aborted by the macro without any errors reported. Macros should issue errors to end-users to facilitate debugging when aborting a macro expansion.", splicePos)
72+
report.error("Macro expansion was aborted by the macro without any errors reported. Macros should issue errors to end-users when aborting a macro expansion with StopMacroExpansion.", splicePos)
7373
// errors have been emitted
7474
EmptyTree
7575
case ex: StopInterpretation =>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
-- Error: tests/neg-macros/annot-ill-abort/Test_2.scala:1:0 ------------------------------------------------------------
3+
1 |@crash // error
4+
|^^^^^^
5+
|Macro expansion was aborted by the macro without any errors reported. Macros should issue errors to end-users when aborting a macro expansion with StopMacroExpansion.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import scala.annotation.{experimental, MacroAnnotation}
2+
import scala.quoted._
3+
4+
@experimental
5+
class crash extends MacroAnnotation {
6+
def transform(using Quotes)(tree: quotes.reflect.Definition): List[quotes.reflect.Definition] =
7+
throw new scala.quoted.runtime.StopMacroExpansion
8+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@crash // error
2+
def test = ()

tests/neg-macros/ill-abort.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-- Error: tests/neg-macros/ill-abort/quoted_2.scala:1:15 ---------------------------------------------------------------
33
1 |def test = fail() // error
44
| ^^^^^^
5-
|Macro expansion was aborted by the macro without any errors reported. Macros should issue errors to end-users to facilitate debugging when aborting a macro expansion.
5+
|Macro expansion was aborted by the macro without any errors reported. Macros should issue errors to end-users when aborting a macro expansion with StopMacroExpansion.
66
|---------------------------------------------------------------------------------------------------------------------
77
|Inline stack trace
88
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

0 commit comments

Comments
 (0)