Skip to content

StringIndexOutOfBoundsException reporting errors in strings with embedded \r #241

@jyn514

Description

@jyn514

the following program crashes instaparse during error reporting:

user=> (pr ((insta/parser "Start = (#'[^x]+' | <'xx'>)+") "\rxa"))
Parse error at line 1, column 2:

Execution error (StringIndexOutOfBoundsException) at jdk.internal.util.Preconditions$1/apply (Preconditions.java:55).
Range [0, 1) out of bounds for length 0

backtrace:

  [java.lang.String checkBoundsBeginEnd "String.java" 4950]
  [java.lang.String substring "String.java" 2912]
  [clojure.core$subs invokeStatic "core.clj" 5040]
  [clojure.core$subs invoke "core.clj" 5034]
  [instaparse.failure$marker invokeStatic "failure.clj" 41]
  [instaparse.failure$marker invoke "failure.clj" 32]
  [instaparse.failure$pprint_failure invokeStatic "failure.clj" 72]
  [instaparse.failure$pprint_failure invoke "failure.clj" 67]
  [instaparse.gll$fn__10113 invokeStatic "gll.clj" 185]
  [instaparse.gll$fn__10113 invoke "gll.clj" 183]
  [clojure.lang.MultiFn invoke "MultiFn.java" 234]
  [clojure.core$pr_on invokeStatic "core.clj" 3700]
  [clojure.core$pr invokeStatic "core.clj" 3703]
  [clojure.core$pr invoke "core.clj" 3703]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions