Closed nicopowa closed 2 years ago
Hi, thank you for the report. May I ask which version of closure you're using? Also, we'll be waiting for a small repro if possible 🙂 From my understanding you're request is to
Would that be correct?
Hi, thanks for your answer !
using JSDoc to annotate VanillaJS ES6 class methods and types, I wrote a method that needs two args : a string and a MediaStreamTrack, typed the JSDoc bloc quickly, specified @param {MediaStreamTrack} track, got the exception again, Fixed the type to non-nullable {!MediaStreamTrack}, and the compiler was happy again !
I'm still not sure how it happened the first time, as I wrote probably because of corrupted externs file.
I'm sending out a PR to make the compiler report more information when it crashes here.
I suspect some internal invariant of the compiler has been violated before we get to LightweightMessageFormatter. It would be useful to figure out where that's happening and fix it.
Closing this issue now that the stack trace for these issues should be more helpful.
@nicopowa if you run into this crash again (after the stack trace fix is released), please do file a new bug.
Hello Closure community,
I have a StringIndexOutOfBoundsException problem sometimes while compiling lots of ES6 Vanilla files and many externs. There are a few posts out there but I couldn't find a solution. I know it comes from my code, usually from bad JSDoc annotations, or generated externs with inconsistencies, but there are no hints or details in the stack trace.
It would be so nice to get the line where the crash comes from ! I'll try to isolate the problem in a minimal example, but it will take some time.
Here's an error :
java.lang.StringIndexOutOfBoundsException: String index out of range: 8 at java.lang.String.charAt(Unknown Source) at com.google.javascript.jscomp.LightweightMessageFormatter.padLine(LightweightMessageFormatter.java:198) at com.google.javascript.jscomp.LightweightMessageFormatter.padMultipleLines(LightweightMessageFormatter.java:252) at com.google.javascript.jscomp.LightweightMessageFormatter.getExcerptWithPosition(LightweightMessageFormatter.java:161) at com.google.javascript.jscomp.LightweightMessageFormatter.format(LightweightMessageFormatter.java:133) at com.google.javascript.jscomp.LightweightMessageFormatter.formatWarning(LightweightMessageFormatter.java:86) at com.google.javascript.jscomp.JSError.format(JSError.java:171) at com.google.javascript.jscomp.PrintStreamErrorReportGenerator.println(PrintStreamErrorReportGenerator.java:56) at com.google.javascript.jscomp.PrintStreamErrorReportGenerator.generateReport(PrintStreamErrorReportGenerator.java:50) at com.google.javascript.jscomp.SortingErrorManager.generateReport(SortingErrorManager.java:116) at com.google.javascript.jscomp.ThreadSafeDelegatingErrorManager.generateReport(ThreadSafeDelegatingErrorManager.java:40) at com.google.javascript.jscomp.Compiler.generateReport(Compiler.java:731) at com.google.javascript.jscomp.AbstractCommandLineRunner.performFullCompilation(AbstractCommandLineRunner.java:1336) at com.google.javascript.jscomp.AbstractCommandLineRunner.doRun(AbstractCommandLineRunner.java:1254) at com.google.javascript.jscomp.AbstractCommandLineRunner.run(AbstractCommandLineRunner.java:533) at com.google.javascript.jscomp.CommandLineRunner.main(CommandLineRunner.java:2150)