From 01f108e34997bb4df2e0c1228aed0dd8c3e9c4c2 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Wed, 10 Sep 2025 09:07:33 +0300 Subject: [PATCH] builtin: fix `v -W -Wimpure-v examples/hello_world.v` (move ctovstring_impl to builtin.c.v) --- cmd/tools/vtest-all.v | 5 +++++ vlib/builtin/builtin.c.v | 13 +++++++++++++ vlib/builtin/string.v | 13 ------------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/cmd/tools/vtest-all.v b/cmd/tools/vtest-all.v index 9933befbd1..137dcb361b 100644 --- a/cmd/tools/vtest-all.v +++ b/cmd/tools/vtest-all.v @@ -90,6 +90,11 @@ fn get_all_commands() []Command { okmsg: 'V can compile hello world.' rmfile: 'examples/hello_world' } + res << Command{ + line: '${vexe} -W -Wimpure-v run examples/hello_world.v' + okmsg: 'V can compile hello world with the stricter `-W -Wimpure-v` mode .' + rmfile: 'examples/hello_world' + } $if linux { if l2w_crosscc != '' { res << Command{ diff --git a/vlib/builtin/builtin.c.v b/vlib/builtin/builtin.c.v index 3910cebfdd..564212a50b 100644 --- a/vlib/builtin/builtin.c.v +++ b/vlib/builtin/builtin.c.v @@ -944,3 +944,16 @@ pub fn arguments() []string { } return res } + +// ctovstring_impl is a temporary API, to enable clean CI runs for https://github.com/vlang/v/pull/25264 . +// It will be deleted after the migration to the new `builtin` naming scheme is finished. +@[export: 'builtin__ctovstring'] +pub fn ctovstring_impl(s &u8) string { + unsafe { + len := C.strlen(voidptr(s)) + return string{ + str: memdup(voidptr(s), isize(len)) + len: len + } + } +} diff --git a/vlib/builtin/string.v b/vlib/builtin/string.v index b3476c4fa8..53f9c87f08 100644 --- a/vlib/builtin/string.v +++ b/vlib/builtin/string.v @@ -3052,16 +3052,3 @@ pub fn (mut ri RunesIterator) next() ?rune { } return rune(impl_utf8_to_utf32(start, len)) } - -// ctovstring_impl is a temporary API, to enable clean CI runs for https://github.com/vlang/v/pull/25264 . -// It will be deleted after the migration to the new `builtin` naming scheme is finished. -@[export: 'builtin__ctovstring'] -pub fn ctovstring_impl(s &u8) string { - unsafe { - len := C.strlen(voidptr(s)) - return string{ - str: memdup(voidptr(s), isize(len)) - len: len - } - } -}