foundweekends / foundweekends/giter8
NullPointerException in ST4 ErrorManager.compileTimeError
- Dominant language
- Scala
- Stars
- 1.8k
- Forks
- 225
- Avg merge
- 2h 35m
- Merged PRs (30d)
- 8
Description
## steps
sbt or Giter8 version: *0.12.1-SNAPSHOT*
```
❯ /Users/jason/.conscript/bin/g8 BotTech/sbt-autoplugin.g8 -b bottech
sbt plugin seed
pluginName [Foo Bar]: Turtles
name [sbt-turtles]:
organizationName [BotTech]:
organization [nz.co.bottech]:
package [nz.co.bottech.sbt.turtles]:
purpose [An sbt plugin]: An sbt plugin for sharing settings between the meta-builds and the main build.
sbtVersion [1.3.10]:
scalaVersion [2.12.11]:
scalacticVersion [3.1.1]:
uTestVersion [0.7.4]:
```
## problem
The root cause is a SYNTAX ERROR:
```
'" =~ 2.1[2]..* && "' came as a complete surprise to me
```
This is then causing a NPE to be thrown when ST4 tries to report the error.
stack trace
```scala
java.lang.NullPointerException
at org.stringtemplate.v4.misc.ErrorManager.compileTimeError(ErrorManager.java:100)
at org.stringtemplate.v4.compiler.Compiler.reportMessageAndThrowSTException(Compiler.java:205)
at org.stringtemplate.v4.compiler.Compiler.compile(Compiler.java:149)
at org.stringtemplate.v4.STGroup.compile(STGroup.java:514)
at org.stringtemplate.v4.ST.(ST.java:173)
at giter8.G8$.applyTemplate(g8.scala:134)
at giter8.G8$.write(g8.scala:185)
at giter8.G8$.write(g8.scala:170)
at giter8.G8$.$anonfun$writeTemplates$3(g8.scala:502)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at scala.util.control.Exception$Catch.$anonfun$opt$1(Exception.scala:246)
at scala.util.control.Exception$Catch.apply(Exception.scala:228)
at scala.util.control.Exception$Catch.opt(Exception.scala:246)
at giter8.G8$.$anonfun$writeTemplates$2(g8.scala:502)
at scala.collection.immutable.Stream.foreach(Stream.scala:533)
at giter8.G8$.writeTemplates(g8.scala:488)
at giter8.G8$.$anonfun$applyT$1(g8.scala:344)
at scala.util.Either$RightProjection.flatMap(Either.scala:701)
at giter8.G8$.applyT(g8.scala:327)
at giter8.G8$.fromDirectory(g8.scala:76)
at giter8.G8TemplateRenderer$.render(TemplateRenderer.scala:40)
at giter8.AppProcessor.process(giter8.scala:58)
at giter8.Runner.$anonfun$run$9(Runner.scala:51)
at scala.util.Either.flatMap(Either.scala:341)
at giter8.Runner.$anonfun$run$5(Runner.scala:48)
at scala.util.Either.flatMap(Either.scala:341)
at giter8.Runner.$anonfun$run$4(Runner.scala:47)
at scala.util.Either.flatMap(Either.scala:341)
at giter8.Runner.run(Runner.scala:46)
at giter8.Giter8.run(giter8.scala:33)
at giter8.Giter8.run(giter8.scala:30)
at giter8.Giter8.run(giter8.scala:26)
at giter8.Giter8.run(giter8.scala:22)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
at xsbt.boot.Launch$.run(Launch.scala:109)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
at xsbt.boot.Launch$.launch(Launch.scala:117)
at xsbt.boot.Launch$.apply(Launch.scala:18)
at xsbt.boot.Boot$.runImpl(Boot.scala:56)
at xsbt.boot.Boot$.main(Boot.scala:18)
at xsbt.boot.Boot.main(Boot.scala)
Unknown exception: null
```
## expectation
## notes
A guard was put in ST4 a long time ago but it was not put in all the right places: https://github.com/antlr/stringtemplate4/commit/7bff6cf014408927b1db4b92406996172f8442e5
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the failure with the shown g8 command, then trace from giter8.G8$.applyTemplate in g8.scala and G8TemplateRenderer$.render in TemplateRenderer.scala into ST4's Compiler and ErrorManager.compileTimeError. Confirm that the reported template syntax error is handled without a NullPointerException and that the resulting error remains informative.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100