@@ -259,6 +259,35 @@ fn test_comptime_for_empty_attrs_does_not_emit_new_array_calls() {
259259 assert ! compilation.output.contains ('.args = builtin____new_array_with_default(0, 0, sizeof(FunctionParam), 0)' )
260260}
261261
262+ fn test_array_push_no_bounds_checking_keeps_max_len_panics () {
263+ os.chdir (vroot) or {}
264+ test_source := os.join_path (os.vtmp_dir (), 'coutput_array_push_no_bounds_checking.vv' )
265+ source_lines := [
266+ 'module main' ,
267+ '' ,
268+ 'fn main() {' ,
269+ '\t mut names := []string{}' ,
270+ "\t names << 'alpha'" ,
271+ '\t mut scores := []int{}' ,
272+ '\t scores << 1' ,
273+ '\t println(names.len + scores.len)' ,
274+ '}' ,
275+ ]
276+ os.write_file (test_source, source_lines.join ('\n ' ) + '\n ' )!
277+ defer {
278+ os.rm (test_source) or {}
279+ }
280+ cmd := '${os.quoted_path(vexe)} -prod -no-bounds-checking -o - ${os.quoted_path(test_source)} '
281+ compilation := os.execute (cmd)
282+ ensure_compilation_succeeded (compilation, cmd)
283+ assert compilation.output.contains ('VV_LOC void builtin__array_push(array* a, voidptr val) {' )
284+ assert compilation.output.contains ('VV_LOC void builtin__array_push_noscan(array* a, voidptr val) {' )
285+ assert ! compilation.output.contains ('array.push: negative len' )
286+ assert compilation.output.contains ('array.push: len bigger than max_int' )
287+ assert ! compilation.output.contains ('array.push_noscan: negative len' )
288+ assert compilation.output.contains ('array.push_noscan: len bigger than max_int' )
289+ }
290+
262291fn test_windows_sharedlive_string_interpolation_in_ternary_does_not_emit_inline_tmp_decl () {
263292 os.chdir (vroot) or {}
264293 test_source := os.join_path (os.vtmp_dir (), 'coutput_live_windows_ternary_str_intp.vv' )
0 commit comments