From 0048a77b0fa1cf5a0ca25281494372c5ebf6bfaa Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 25 Mar 2026 22:57:47 +0300 Subject: [PATCH] js: fix array.get index out of range panic (fixes #11379) --- vlib/v/gen/js/jsgen_test.v | 12 ++++++++++++ .../testdata/js_browser_builtin_print_regression.v | 4 ++++ 2 files changed, 16 insertions(+) create mode 100644 vlib/v/gen/js/tests/testdata/js_browser_builtin_print_regression.v diff --git a/vlib/v/gen/js/jsgen_test.v b/vlib/v/gen/js/jsgen_test.v index 2dc22416a..36d669350 100644 --- a/vlib/v/gen/js/jsgen_test.v +++ b/vlib/v/gen/js/jsgen_test.v @@ -61,6 +61,18 @@ fn test_example_compilation() { } } +fn test_issue_11379_js_browser_builtin_print_call_does_not_panic() { + vexe := os.getenv('VEXE') + os.chdir(os.dir(vexe)) or {} + os.mkdir_all(output_dir) or { panic(err) } + program := os.join_path(test_dir, 'testdata', 'js_browser_builtin_print_regression.v') + output := os.join_path(output_dir, 'js_browser_builtin_print_regression.js') + res := os.execute('${os.quoted_path(vexe)} -enable-globals -b js_browser -o ${os.quoted_path(output)} ${os.quoted_path(program)}') + assert res.exit_code == 0, res.output + assert !res.output.contains('V panic:'), res.output + assert os.exists(output) +} + fn find_test_files() []string { files := os.ls(test_dir) or { panic(err) } // The life example never exits, so tests would hang with it, skip diff --git a/vlib/v/gen/js/tests/testdata/js_browser_builtin_print_regression.v b/vlib/v/gen/js/tests/testdata/js_browser_builtin_print_regression.v new file mode 100644 index 000000000..c155a6987 --- /dev/null +++ b/vlib/v/gen/js/tests/testdata/js_browser_builtin_print_regression.v @@ -0,0 +1,4 @@ +// issue #11379: this used to panic in the checker for `-b js_browser`. +fn main() { + JS.print('hello vtic', 32, 32) +} -- 2.39.5