Exception when printing error message for simple syntax error

Create issue
Issue #267 resolved
Jesper Öqvist created an issue

JastAdd 2.2.2 prints a stack trace instead caused by using a token as a format string during error reporting. Here is a test case:

aspect Test {
  syn String A.v() = "%s

Here is the JastAdd output:

java.util.MissingFormatArgumentException: Format specifier '%s'
     at java.util.Formatter.format(Formatter.java:2519)
     at java.util.Formatter.format(Formatter.java:2455)
     at java.lang.String.format(String.java:2940)
     at org.jastadd.Problem$ProblemBuilder.message(Problem.java:46)
     at org.jastadd.JastAdd.parseAspect(JastAdd.java:558)
     at org.jastadd.JastAdd.readJragFiles(JastAdd.java:292)
     at org.jastadd.JastAdd.compile(JastAdd.java:184)
     at org.jastadd.JastAdd.compile(JastAdd.java:130)
     at org.jastadd.JastAdd.main(JastAdd.java:115)]>

Comments (3)

  1. Jesper Öqvist reporter

    Add non-formating message method to ProblemBuilder

    Added a non-formating message method to ProblemBuilder to avoid inadvertent use of literal messages as format strings.

    fixes #267 (bitbucket)

    → <<cset 6a5632f8db28>>

  2. Log in to comment