Bug: Getting a substring never causes 'out of index' error #543

Closed
hajimehoshi opened this Issue Oct 30, 2016 · 2 comments

Projects

None yet

3 participants

@hajimehoshi
Contributor

http://www.gopherjs.org/play/#/S6teI-bnkF

package main

import (
    "fmt"
)

func main() {
    str := "foo"
    fmt.Println(str[0:999])
}

This should cause an error panic: runtime error: slice bounds out of range but not.

@hajimehoshi hajimehoshi changed the title from Bug: Get a substring never causes 'out of index' error to Bug: Getting a substring never causes 'out of index' error Oct 30, 2016
@shurcooL shurcooL added the bug label Oct 30, 2016
@shurcooL
Member
shurcooL commented Oct 30, 2016 edited

Thanks for reporting, this is a bug. I can reproduce.

@neelance neelance added a commit that referenced this issue Oct 31, 2016
@neelance neelance add bounds check for SliceExpr on string (fixes #543) a9c3bca
@neelance neelance added a commit that closed this issue Oct 31, 2016
@neelance neelance add bounds check for SliceExpr on string (fixes #543) e34a5cd
@neelance neelance closed this in e34a5cd Oct 31, 2016
@neelance
Member

@hajimehoshi Thanks a lot for reporting this bug! :)

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