Skip to content

fix: support two-way bindings to nested model fields - #37

Merged
medvednikov merged 1 commit into
masterfrom
fix/issue-27-20260919
Sep 19, 2026
Merged

medvednikov merged 1 commit into
masterfrom
fix/issue-27-20260919

Conversation

@medvednikov

Copy link
Copy Markdown
Member

Fixes #27.

Changes

Support nested struct paths such as bind.text: app.profile.name instead of limiting two-way bindings to direct app fields. Validate that every path segment is public and mutable, and write the supported scalar leaf in place. Boolean and numeric binding checks use the leaf's type.

Add regression tests covering multi-level text writes before an action reads the updated model, boolean and numeric controls, and rejection of private, immutable, missing, non-traversable, and incorrectly typed fields. Update the README with nested binding syntax.

Event-assignment syntax remains top-level-only; this PR changes two-way bindings, not action-expression semantics. Traversal is through value structs, not interface or pointer writes.

Verification

Passed with V 0.5.2:

v -d ui2_headless test ui/vml_nested_binding_test.v
v -d ui2_headless test ui/vml_model_test.v

The new regression fails against the original code and passes with this change. Both commands also passed on the Linux runner before commit/publication: verification log. The shared run later stopped on an existing scrolling-test compilation failure for a different issue.

The new nested-binding tests also passed locally under AddressSanitizer (-cc gcc -gc none, address sanitization enabled, leak detection disabled). No temporary verification infrastructure is included in this PR.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 19, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-19T14:05:22.885203Z 0684add PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0684addac9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ui/vml_binding_path.v
Comment on lines +16 to +17
if parts.len == 1 {
return typeof(field).name

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject unsupported nested leaves during template validation

When a bind.text path ends at a public mutable struct or another unsupported type—for example, app.section.values—this returns that type successfully, and v_validate_node_schema performs no leaf-type check for text bindings. Consequently new_vml_app accepts the document and renders an empty/stringified value, but the first edit fails in vml_set_path with “two-way binding does not support…” instead of reporting the invalid binding while loading the template. This is newly reachable for multi-segment targets because the previous top-level-path restriction rejected them; validate that the leaf is one of the setter-supported scalar types before accepting the binding.

Useful? React with 👍 / 👎.

@medvednikov
medvednikov merged commit d04e69f into master Sep 19, 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.

Binding to non-top-level properties

1 participant