fix: reflect interface fields in VML repeaters - #38
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: a90f40ce8a
ℹ️ 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".
| mut fields := map[string]VValue{} | ||
| $for field in E.fields { | ||
| $if field.is_pub { | ||
| fields[field.name] = v_value_from(value.$(field.name)) |
There was a problem hiding this comment.
Guard zero interface values before reflecting fields
When a public model field uses an interface with declared fields but is left at its zero value, v_value_from eagerly converts that field even if the VML never references it, and this selector dereferences an interface with no backing object. That makes otherwise unrelated template rendering crash; previously, unsupported interface fields became an invalid VValue without being dereferenced. Detect a zero/nil-backed interface and return an invalid value or an actionable error before selecting its fields.
Useful? React with 👍 / 👎.
Fixes #26.
Changes
Add interface-aware VML value and schema conversion. Runtime values expose the public fields declared by the interface; schema construction uses each declared field's type rather than selecting fields from a zero interface, so an empty
[]Itemcan still validate safely.Regression coverage includes mixed value-backed and pointer-backed implementations,
item.idkeys anditem.labelrendering, action arguments, stable event identities after reordering, duplicate-key rejection, empty collections, and rejection of fields outside the interface contract.Verification
Passed with V 0.5.2:
The new regression fails with
cannot read id from item.idagainst the original code and passes with this change. Both commands also passed on Linux before branch publication: verification log. That shared run subsequently failed on an existing scrolling-test compilation error while checking a different issue.The interface regression tests also passed locally under AddressSanitizer (
-cc gcc -gc none, leak detection disabled). This is an independent PR against master and includes no temporary verification workflow.