/
nv-lang
/
nova
Обзор
Документация
Войти
/
nv-lang
/
nova
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
std/src/collections/vec/core_test.nv
45 строк
2 KB
Evgeniy Golovin
test(221.1 №364): снять as-каст-обходы для Some(лит), фикс §2 закрыл нужду
06 авг 2026, 01:09
06 авг 2026, 01:09
affded8
Код
Авторство
О чём код?
// SPDX-License-Identifier: MIT OR Apache-2.0 // std.collections.vec (core tests) — Vec[T] type, constructors, len/cap. #prelude(core, runtime, collections, protocols) module collections.vec test "new(cap: n) / reserve" { mut v = Vec[int].new(cap: 16) assert(v.cap() >= 16) assert(v.len() == 0) for i in 0..10 { v.push(i) } assert(v.len() == 10) v.reserve(20) assert(v.cap() >= 30) } test "grow — 1000 pushes preserve order" { mut v = (0..1000).collect() assert(v.len() == 1000) assert(v.get(0) == Some(0)) assert(v.get(500) == Some(500)) assert(v.get(999) == Some(999)) } // [M-rawmem-typed-copy-wrappers] regression (2026-07-08): `@cap`'s realloc // path calls the generic `RawMem.copy_n_nonoverlapping[T]` wrapper (static // fn owning its OWN `[T]`, on the non-generic `RawMem` type — a shape no // other stdlib call used). `infer_type_param_binding` had no arm for // `*T`/`*mut T` params, so T never bound from call-site args; the ONE call // site that DID have a fallback silently defaulted every unresolved T to // `nova_str`, so every non-str `Vec[T]` reused the str-mono'd wrapper (wrong // pointer type + wrong `size_of[T]()` stride) — silent heap corruption, not // a compile error. `Vec[u8]` pushed past the initial capacity was the // smallest repro. Fixed by adding the missing Pointer/Mut/Unsafe arm to // `infer_type_param_binding` (emit_c.rs) and turning the silent fallback // into a loud `?` propagation. test "grow — Vec[u8] past initial capacity (non-str T mono regression)" { mut v = Vec[u8].new() for i in 0..40 { v.push(i as u8) } assert(v.len() == 40) assert(v.get(0) == Some(0)) assert(v.get(5) == Some(5)) assert(v.get(39) == Some(39)) }