Skip to content

windows: copy handles through voidptr() where a mutable copy of an immutable handle is taken - #105

Merged
diiviocity merged 1 commit into
vlang:masterfrom
torial:windows-ui-w-notices
Oct 29, 2026
Merged

diiviocity merged 1 commit into
vlang:masterfrom
torial:windows-ui-w-notices

Conversation

@torial

@torial torial commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

The follow-up offered on #104: the five mutability notices in windows/ui_windows.v.

V master's checker refuses mut h := outer when outer is an immutable pointer (outer is immutable, cannot have a mutable reference to an immutable object), so a -W build of any example on Windows stopped on five lines: set_text, windows_create_element, windows_apply_element, ui2_windows_context_menu and ui2_windows_cursor. Each is a window handle copied so the copy can be re-pointed (walked up to a parent, swapped for a label's inner control). The copy is now spelled voidptr(x), which says that a new handle value is taken, not a reference to the variable. No behaviour change.

Verified on Windows 11 with V master (77e34807 + a driver patch, tcc and llvm-mingw clang):

  • v -N -W -cc tcc examples/editor before: the five errors above; after: none in windows/ui_windows.v.
  • v -cc tcc examples/editor (native) and v -cc clang -d ui2_custom_rendering examples/gpui_editor build.
  • v -enable-globals -cc tcc test windows/ui_windows_test.v passes. Under -N -W it stops on six notices in the test file itself (lines 163, 215, 367, 368, 381, 382), the same before and after; none in ui_windows.v.
  • v fmt -verify clean.

Seen but left, since they are not Windows code: under V master -N the examples still stop on four cross-platform notices (grid shadows a function in ui/component_color.v twice and ui/component_plot_axis.v, an uninitialised fn field in ui/frame_scheduler.v; scale shadows a function in three files under the custom renderer). They are notices on 0.5.2, which the CI pins.

🤖 Generated with Claude Code

…mutable handle is taken

V master's checker refuses `mut h := outer` when `outer` is an immutable
pointer ("cannot have a mutable reference to an immutable object"), so a
`-W` build of any example stopped on five such lines in ui_windows.v
(set_text, windows_create_element, windows_apply_element,
ui2_windows_context_menu, ui2_windows_cursor). Each is a handle copied to
walk or re-point; the copy is spelled `voidptr(x)`, which says so.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@torial

torial commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

The red checks here are not this branch's. The Build examples jobs fail on master itself (run 40932097242 on 8442360, every job) with the same first errors, in files this change does not touch: ui/animation.v:844 (array2 = array1.clone()), ui/clipboard_nix.v:66 (os.Process.set_stdin_path), ui/component_basics.v:32 (math.max with an f64), and ui/clipboard_windows.c.v:13 (uint) on Windows. The workflow downloads the V 0.5.2 release, which no longer builds ui2 master; the 0.5.2 at 7647ce1 here refuses uint the same way, while V master builds the examples. So the choice is between moving the pin and keeping the newer code, which is yours to make; this branch only takes the five -W lines out of windows/ui_windows.v.

@diiviocity

Copy link
Copy Markdown
Member

lgtm

@diiviocity
diiviocity merged commit 877da6b into vlang:master Oct 29, 2026
0 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants