Skip to content

Commit f094525

Browse files
committed
Add a hint for nested class problem when dup fails (issue 66)
1 parent b06fd59 commit f094525

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

core/src/org/kiama/rewriting/RewriterCore.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ trait RewriterCore {
433433
ctor.newInstance (children : _*).asInstanceOf[T]
434434
} catch {
435435
case e : IllegalArgumentException =>
436-
sys.error (s"""dup illegal arguments: $ctor (${children.mkString (",")}), expects ${ctor.getParameterTypes.length}""")
436+
sys.error (s"""dup illegal arguments: $ctor (${children.mkString (",")}), expects ${ctor.getParameterTypes.length}
437+
|Common cause: term classes are nested in another class, move them to the top level""".stripMargin)
437438
}
438439
}
439440

library/src/org/kiama/rewriting/RewriterTests.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,8 @@ class RewriterTests extends Tests with Generator {
10451045
val arg1type = "org.kiama.example.imperative.ImperativeTree$Var"
10461046
val arg2type = "org.kiama.example.imperative.ImperativeTree$Exp"
10471047
val error = "(Num(42.0),Num(99.0)), expects 2"
1048-
val msg = "%s: %s(%s,%s) %s".format (base, method, arg1type, arg2type, error)
1048+
val hint = "Common cause: term classes are nested in another class, move them to the top level"
1049+
val msg = "%s: %s(%s,%s) %s\n%s".format (base, method, arg1type, arg2type, error, hint)
10491050
assertResult (msg) (i.getMessage)
10501051
}
10511052

0 commit comments

Comments
 (0)