Skip to content

Commit 01ae7dd

Browse files
authored
Merge pull request #1629 from ljdelight/errorMessages
Update error msg for Parsers.scala:1738 and 1739
2 parents b4f0c6e + 7c47361 commit 01ae7dd

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,8 +1742,8 @@ object Parsers {
17421742
if (owner == nme.CONSTRUCTOR && (result.isEmpty || (result.head take 1 exists (_.mods is Implicit)))) {
17431743
in.token match {
17441744
case LBRACKET => syntaxError("no type parameters allowed here")
1745-
case EOF => incompleteInputError("auxiliary constructor needs non-implicit parameter list")
1746-
case _ => syntaxError("auxiliary constructor needs non-implicit parameter list", start)
1745+
case EOF => incompleteInputError(AuxConstructorNeedsNonImplicitParameter())
1746+
case _ => syntaxError(AuxConstructorNeedsNonImplicitParameter(), start)
17471747
}
17481748
}
17491749
result

src/dotty/tools/dotc/reporting/diagnostic/messages.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,4 +715,21 @@ object messages {
715715
|""".stripMargin
716716
}
717717
}
718+
719+
case class AuxConstructorNeedsNonImplicitParameter()(implicit ctx:Context) extends Message(26) {
720+
val kind = "Syntax"
721+
val msg = "auxiliary constructor needs non-implicit parameter list"
722+
val explanation =
723+
hl"""Only the primary constructor is allowed an ${"implicit"} parameter list;
724+
|auxiliary constructors need a non-implicit parameter list. When a primary
725+
|constructor has an implicit argslist, auxiliary constructors that call the
726+
|primary constructor must specify the implicit value.
727+
|
728+
|To resolve this issue check for:
729+
| - forgotten parenthesis on ${"this"} (${"def this() = // ..."})
730+
| - auxiliary constructors specify the implicit value
731+
|""".stripMargin
732+
}
733+
734+
718735
}

0 commit comments

Comments
 (0)