Skip to content

Commit 492c100

Browse files
Merge pull request #8960 from dotty-staging/fix-#7839
Fix #7839: Improve error message for implicit parameters
2 parents 22d841a + 8cbec92 commit 492c100

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,12 @@ object Splicer {
160160
// OK
161161

162162
case _ =>
163+
val extra = if tree.span.isZeroExtent then ": " + tree.show else ""
163164
ctx.error(
164-
"""Malformed macro parameter
165+
s"""Malformed macro parameter$extra
165166
|
166-
|Parameters may be:
167+
|Parameters may only be:
167168
| * Quoted parameters or fields
168-
| * References to inline parameters
169169
| * Literal values of primitive types
170170
|""".stripMargin, tree.sourcePos)
171171
}

tests/neg-macros/i7839.check

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- Error: tests/neg-macros/i7839.scala:4:18 ----------------------------------------------------------------------------
2+
4 | ${ transformImpl } // error
3+
| ^
4+
| Malformed macro parameter: dummyImplicit
5+
|
6+
| Parameters may only be:
7+
| * Quoted parameters or fields
8+
| * Literal values of primitive types

tests/neg-macros/i7839.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import scala.quoted._
2+
3+
inline def transform(using dummyImplicit: DummyImplicit): Unit =
4+
${ transformImpl } // error
5+
6+
def transformImpl(using dummyImplicit: DummyImplicit)(using QuoteContext): Expr[Unit] = ???

0 commit comments

Comments
 (0)