[stdlib][collections] Improve InlineArray comptime out-of-bounds diagnostic (fix #6334) by mahendrarathore1742 · Pull Request #6342 · modular/modular

Pull request overview

Improves compile-time (comptime interpreter) out-of-bounds diagnostics for InlineArray indexing, addressing issue #6334 by providing a clearer, source-level error and adding a regression test to prevent the generic interpreter/pass-manager failure from resurfacing.

Changes:

  • Added a comptime-interpreter-specific bounds check in InlineArray.__getitem__ to surface an explicit out-of-bounds diagnostic.
  • Improved the compile-time bounds-check failure message in InlineArray.__getitem_param__.
  • Added and registered a compile-fail regression test for nested comptime for indexing (points[i + 1]).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
mojo/stdlib/std/collections/inline_array.mojo Adds comptime-interpreter OOB diagnostic in __getitem__ and improves __getitem_param__ message text.
mojo/stdlib/test/collections/test_inline_array_comptime_oob_compile_fail.mojo New compile-fail regression test that checks for an InlineArray OOB diagnostic during comptime evaluation.
mojo/stdlib/test/collections/BUILD.bazel Registers the new lit test in the collections test target.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.