/
nv-lang
/
nova
Обзор
Документация
Войти
/
nv-lang
/
nova
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
std/src/collections/vec/protocols_test.nv
45 строк
2 KB
Evgeniy Golovin
fix(codegen): [M-208-generic-interp-display-dispatch-gap] закрыт — bare ${vec}/${vec:?} теперь диспетчит на собственный @display/@debug generic-контейнера
17 июл 2026, 13:19
17 июл 2026, 13:19
a49804b
Код
Авторство
О чём код?
// SPDX-License-Identifier: MIT OR Apache-2.0 // std.collections.vec (protocols tests) — Display/Debug (Plan 208 Ф.3, D422). // // Test 1 keeps the direct `.display(FmtCtx.bare(...))` call form (same shape // as `protocols.nv`'s own doc-comment example) as its OWN contract — a real, // distinct code path (the general method-call dispatch), not a workaround. // Tests 2-4 use bare `${v}`/`${v:?}` interpolation, which used to hit a // separate PRE-EXISTING codegen dispatch gap // ([M-208-generic-interp-display-dispatch-gap], now CLOSED — see // `try_generic_mono_interp_dispatch` in `compiler-codegen/src/codegen/ // emit_c.rs` and spec_tests/conformance/d422_generic_interp_dispatch.nv): // `emit_interpolated_str`'s `all_methods` lookup was keyed by the exact // mono-mangled C type name (e.g. `Vec____nova_int`), but the impl below is // registered under the generic base name `Vec` — the lookup missed and fell // through to a numeric-cast fallback that printed the receiver's raw // pointer as an int. This predated Plan 208 (confirmed: no fixture anywhere // ever exercised `${vec}`/`${vec:?}` before this test file was added) and // was tracked as a follow-up (see docs/plans/208-impl-progress.md // §НАХОДКА) — now fixed, so these tests exercise the real sugar form // instead of working around it. #prelude(core, runtime, collections, protocols) module collections.vec test "Vec[T] Display: Vec[e0, e1, ...] via direct .display(FmtCtx.bare(...))" { ro v = Vec[int].of(1, 2, 3) consume sb = StringBuilder.new() v.display(FmtCtx.bare(sb, 0, false)) assert(sb.into_str() == "Vec[1, 2, 3]") } test "Vec[T] Debug: bare ${v:?} interpolation (same shape as Display — no field names to diverge over)" { ro v = Vec[int].of(1, 2, 3) assert("${v:?}" == "Vec[1, 2, 3]") } test "Vec[T] Display: empty vector via bare ${v} interpolation" { ro empty = Vec[int].new() assert("${empty}" == "Vec[]") } test "Vec[T] Display: nested — elements format via their OWN @display (str quoted only under Debug), bare interpolation" { ro v = Vec[str].of("a", "b") assert("${v}" == "Vec[a, b]") assert("${v:?}" == "Vec[\"a\", \"b\"]") }