You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
One-liners and the REPL have no bounds checks: with -e 'print(f"{[1, 2][5]}")' reads past the end and exits 0 #2268
In with -e/-n/-p (and the REPL), indexing or slicing past the end does not panic. It reads out of bounds and the program exits 0. The same code in a file panics with "index out of bounds" under with run or with build (exit 134), as D71 says. The spec allows unchecked indexing only in release builds (types.md §4.3a: "Bounds checking in debug mode, unchecked in release"), and a one-liner is not a release build.
$ with -e 'let a = [1, 2]' -e 'print(f"{a[5]}")'
0 # exit 0
$ printf 'one\n' | with -n 'print(line.split(" ")[1])'
# an empty line, exit 0
$ printf 'let a = [1, 2]\nprint(f"{a[5]}")\n' > t.w && with run t.w
panic: index out of bounds # exit 134
-O0 doesn't change the one-liner result. panic("x") in -e does panic, so the runtime panic path works there.
Cause. The checks are emitted only when debug info is on. mir_emit_debug_index_bounds_check and mir_emit_debug_slice_bounds_check return at once when self.debug_info == 0 (src/CodegenDispatch.w:7999, :8018). run_one_liner_command calls comp.set_debug_info(false) (src/main.w:843), and run_repl_line does the same (:5528). So the safety check depends on a setting that is about debugging output. This matters most for one-liners: awk-style line.fields()[1] on a short line should panic (the cheat sheet in #2127 says so), and instead it silently prints "".
Fix direction (your call). Gate the bounds checks on the release setting, not on debug info, so a build without debug info still checks. Or turn debug info on for one-liners and the REPL. The first follows the spec's wording.
Checked on Linux x86_64 (WSL2) with the seed nightly-20261005-local-1-3207aacb2c74 and with stage1 of main 1f946c14; the two lines cited are unchanged on main 1917e058.
Fixed on main by e3b0ad0 (PR #2664, stack #2668; battery green on the stack top 9f92dbb). The commit message names the root-cause line and the regression test.
Thanks! Confirmed on main 8b297e36 (Linux x86_64): every shape from the report now panics with "index out of bounds" (exit 134): with -e, with -n, with -p, the REPL, and a slice past the end ("slice index out of bounds"). --release stays unchecked, as §4.3a says.
Activity
ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): reproduced.pre-release: a one-liner reads out of bounds silently where a file panics (D71); one-liners are a stated priority.
Codegen: index and slice bounds are checked in every build but --rele…
ehartford commentedon Oct 25, 2026
Fixed on main by e3b0ad0 (PR #2664, stack #2668; battery green on the stack top 9f92dbb). The commit message names the root-cause line and the regression test.
joshhickson commentedon Oct 28, 2026
Thanks! Confirmed on main
8b297e36(Linux x86_64): every shape from the report now panics with "index out of bounds" (exit 134):with -e,with -n,with -p, the REPL, and a slice past the end ("slice index out of bounds").--releasestays unchecked, as §4.3a says.ehartford commentedon Oct 28, 2026
I apprecite your contributions Josh.