Skip to content

Conversation

@ireina7
Copy link

@ireina7 ireina7 commented Oct 27, 2020

Original Code in package.scala:

private def parseRec(s : String) : (Int,String,String) = if(s.isEmpty)  (0,s,s) else {
    s.head match {
      ...
      case 'L' => {
        val end = s.indexOf(';')
        if(end < 0) sys.error("Malformed type (sub)string: " + s)
        (1, s.substring(0, end), s.substring(end + 1, s.size))
      }
      ...
      case _ => sys.error("Malformed type (sub)string: " + s)
    }
  }

I think the original code case 'L' => {... (1, s.substring(0, end), ...) ...} should be be case 'L' => {... (1, s.substring(0, end + 1), ...) ...} since the parameter end in method substring is exclusive, therefore:

After

private def parseRec(s : String) : (Int,String,String) = if(s.isEmpty)  (0,s,s) else {
    s.head match {
      ...
      case 'L' => {
        val end = s.indexOf(';')
        if(end < 0) sys.error("Malformed type (sub)string: " + s)
        (1, s.substring(0, end + 1), s.substring(end + 1, s.size))
      }
      ...
      case _ => sys.error("Malformed type (sub)string: " + s)
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants