[Chapel Merge] Fixed 17457

Branch: refs/heads/master
Revision: 8ab2cd1
Author: bradcray
Log Message:

Merge pull request #17458 from piyush0411/Fix17457

Fixed 17457

[contributed by @piyush0411, reviewed by me]

Fixes #17457

Tested with the following input.

use List;
var l: list(int);
writeln(l.indexOf(3));

The output comes out to be -1, as required.

[editor: approach was simply to check for size == 0 lists before doing any OOB checks; this PR also adds a test locking in the new behavior]

Modified Files:
A test/library/standard/List/indexOf/listIndexOfEmptyList.chpl

A test/library/standard/List/indexOf/listIndexOfEmptyList.good
M modules/standard/List.chpl

Compare: https://github.com/chapel-lang/chapel/compare/a7cdc7b462a4...8ab2cd101082