Skip to content

Arrays and Slices says the last line will cause a compiler error when it doesn't #1575

Closed
@nathanheffley

Description

@nathanheffley

Arrays and Slices has an example at the bottom of the code example of an index out of bounds error, and the comment implies that it will cause a compiler error if you uncomment the line. But if you go ahead and uncomment the line the example will compile just fine and run until it panics because of the out of bounds error.

I figured out that all of the lines that borrow the xs value seem to be what interferes with the compilers ability to preemptively catch the error, but it was pretty confusing to me as someone who doesn't work with compilers all that extensively.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions