Repository navigation
Fix statement and comment handling in the patched Vize event handlers - #159
Merged
Merged
Conversation
The patched Vize copies retried any text that failed to parse as an
expression as a list of statements, wherever the text appeared. So an
event handler such as `if (ok) run()`, or `a; b` in a bound attribute,
an interpolation, or a `v-if`, compiled without a diagnostic into
JavaScript that the browser cannot parse. `@vue/compiler-core` reads text
as statements only for an event handler that contains `;`, and reports
everything else as an invalid expression.
In `vize_atelier_core` and `vize_s1_to_s2`:
- read text as statements only for an event handler that contains `;`,
in the TypeScript fallback too. `vize_atelier_core` reports other
statements as invalid expressions. `vize_s1_to_s2` refuses them, so
`vize_atelier_dom` falls back to `vize_atelier_core`, which reports the
diagnostic.
- require the handler reference and function checks to match the whole
text, so `a; b()` compiles to `$event => {_ctx.a; _ctx.b()}` instead of
being written unwrapped as if it were the reference `a`. With `is_ts`,
both checks read the text after its TypeScript syntax is removed, so
`foo!` is still passed on as the reference `foo`.
- write line comments in an event handler as block comments, so a
trailing `// note` cannot hide the closing `}` of `$event => {...}` or
the `,` before the next prop. Vue itself writes the comment unchanged
here, which produces code that does not parse.
New regression tests in both crates compare the written handlers with
the output of `@vue/compiler-dom` 3.5.42 and, where they expect compiled
output, check that the render code parses. Each `README.citry.md` lists the changed files and
the new tests.
Refs #138
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The statement and comment fixes change what the crates compile, so the local version label moves on. Also describe the copies without the word "vendor", per the house style. Refs #138 Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec
added a commit
that referenced
this pull request
Oct 1, 2026
Take the final Vize sources from #159 (statement and comment handling in event handlers, with its review fixes and regression tests) and label the crates 0.420.0+citry.2, since what they compile changed. The compiler identity Citry records moves with the label. Refs #138 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(Opus 5.5)
Citry's patched copies of the Vize compiler crates (
vize_atelier_coreandvize_s1_to_s2, added in #140) can turn some Vue templates into JavaScript that the browser cannot parse, without reporting an error. This PR fixes how the two crates read event handlers and other template expressions, so their output and diagnostics match@vue/compiler-core. The two exceptions, described below, are cases where Vue's own output does not parse.What goes wrong today
When the text could not be parsed as one expression, the crates tried again and read it as a list of statements. They did this everywhere, not only in event handlers. Vue reads text as statements only for an event handler that contains
;. In every other case it reports an invalid expression.With Citry's options (
prefix_identifierson), the current crates produce:@click="a; b()"onClick: _ctx.a; _ctx.b()(does not parse)onClick: $event => {_ctx.a; _ctx.b()}@click="if (ok) run()"$event => ($event => (if (_ctx.ok) _ctx.run())):title="a; b",{{ a; b }},v-if="a; b"@click="count++; log() // note"$event => {$event => {_ctx.count++; _ctx.log() // note}}(the comment hides the closing braces)$event => {_ctx.count++; _ctx.log() // note}(no error, but this does not parse either)What changes
In both crates:
;. This also applies to the TypeScript fallback. Elsewhere,vize_atelier_corereports statements as invalid expressions.vize_s1_to_s2refuses them, sovize_atelier_domfalls back tovize_atelier_coreand reports the same diagnostic.handler) or a function (() => run()) now require that one expression to be the whole text.a; b()compiles to$event => {_ctx.a; _ctx.b()}, the same output Vue produces. For() => run(); log(), Vue checks only the first statement and writes the text unwrapped, which does not parse. These crates write$event => {() => _ctx.run(); _ctx.log()}instead. With TypeScript on (is_ts), both checks read the text after its type syntax is removed, so@click="foo!"is still passed on as the reference_ctx.foo.// notecan no longer hide the closing}of$event => {...}or the,before the next prop. A//inside a string is left alone. Vue writes the comment unchanged, so its output forcount++; log() // notedoes not parse.Each crate's
README.citry.mdlists the changed files and the new tests.Why this lands before #137
#137 moves Citry's Vue rendering onto these crates through
citry_vue_compiler. It already contains an earlier version of this change (its commit 372558a). This PR adds the fixes and tests that a review of that version found necessary. Merging it here first keeps #137 smaller, and lets this compiler change be reviewed separately from the Vue migration. After this PR merges, #137 should drop its copy of the commit and rebase.How it was tested
On
mainthese crates are not workspace members, and their manifests (copied from the crates.io archives) do not declare the development dependencies their tests use. As a result, the Rust tests workflow does not build or test them. To test them, I copied both crates into a temporary Cargo workspace. That workspace adds the missing published development dependencies (insta,toml,vize_atelier_dom,vize_atelier_sfc,vize_croquis,vize_s1,vize_s2,vize_davinci) and patches crates.io to the local copies, as #137 does.vize_atelier_core/tests/event_handler_statements.rs(6 tests) andvize_s1_to_s2/tests/citry_event_handler_statements.rs(7 tests) cover each case above. To write them, I ran the crates and@vue/compiler-dom3.5.42 on the same templates withprefixIdentifiers: true, and then copied the observed handlers into the assertions. When Vue's own output does not parse, the test says so. Each test that expects compiled output also checks that the render code parses as JavaScript.mainsource restored, 11 of the 13 tests fail. The other two,typescript_handler_reference_stays_a_referencein each crate, pass onmain. They guard against a regression that the whole-text check would otherwise introduce forfoo!. I also turned off each part of the fix one at a time, and for each part at least one test failed. The parts are: the TypeScript fallback, the whole-text check, the TypeScript reference check, the comment conversion invize_atelier_corecodegen, and the three comment conversions invize_s1_to_s2(block bodies, prefixed handlers, and unprefixed handlers).vize_atelier_dom::compile_template_with_optionswith Citry's options. Before the fix, none of@click="if (ok) run()",:title="a; b", and{{ a; b }}reported an error. After it, all three reportInvalidExpression, and@click="a; b()"and the trailing-comment handler compile to code that parses.legacyfeature onvize_atelier_coreand thetypescriptfeature onvize_s1_to_s2, 1,058 tests pass after this change, compared with 1,045 before it. The 13 new tests account for the difference. The same 6 tests fail before and after this change. Five are upstream tests whose expected output predates the Vendor patched Vize compiler crates #140 patches (quoted modifier keys and keyed children in conditional fragments). The sixth,the_matrix_plane_is_metamorphically_stable, reads fixture files that exist only in the upstream repository. Nine targets cannot build outside the upstream Vize repository, because they need its unpublished test crates (davinci_harness,davinci_test_support) or feature-gated corpora.cargo fmt --checkpasses for both crates.cargo clippy -- -D warningspasses for both libraries and the new test targets.Refs #138, which tracks sending these fixes upstream and removing the local copies.
🤖 Generated with Claude Code