fix: support two-way bindings to nested model fields - #37
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
| if parts.len == 1 { | ||
| return typeof(field).name |
There was a problem hiding this comment.
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 👍 / 👎.
Fixes #27.
Changes
Support nested struct paths such as
bind.text: app.profile.nameinstead 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:
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.