-
Notifications
You must be signed in to change notification settings - Fork 23
chore(deps): Bump openjd-* Rust crates to 0.7.0 #359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -106,8 +106,15 @@ impl PyFormatString { | |||||||||||||
| /// checking through the expression tree. | ||||||||||||||
| /// | ||||||||||||||
| /// Mirrors the Rust crate's | ||||||||||||||
| /// `FormatString::validate_expressions(symtab, lib)`. Returns | ||||||||||||||
| /// `None` on success. | ||||||||||||||
| /// `FormatString::validate_expressions(symtab, lib, target_type)`. | ||||||||||||||
|
leongdl marked this conversation as resolved.
|
||||||||||||||
| /// Returns `None` on success. | ||||||||||||||
| /// | ||||||||||||||
| /// `target_type` is passed as `None` because `resolve` and | ||||||||||||||
| /// `resolve_string` above resolve without one; validation has to | ||||||||||||||
| /// observe the same values resolution will produce. The crate | ||||||||||||||
| /// returns a `StaticResolution` (resolved-length bound and, when | ||||||||||||||
| /// fully concrete, the resolved value); this binding is pass/fail | ||||||||||||||
| /// only and discards it. | ||||||||||||||
| #[pyo3(signature = (symtab, *, profile=None))] | ||||||||||||||
| fn validate_expressions( | ||||||||||||||
| &self, | ||||||||||||||
|
|
@@ -117,7 +124,8 @@ impl PyFormatString { | |||||||||||||
| let st = extract_symtab(symtab)?; | ||||||||||||||
| let lib = profile_for_call(profile); | ||||||||||||||
| self.inner | ||||||||||||||
| .validate_expressions(&st, &lib) | ||||||||||||||
| .validate_expressions(&st, &lib, None) | ||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The escaping bug this PR is regression-testing for format!("FormatString(\"{}\")", self.inner.raw())which interpolates the raw source with no escaping at all — not even for the
This matters more than usual here because Given openjd-rs#374 added the escaping writer for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, and out of scope for this PR. Reproduced through the binding — all three of your cases:
And Not fixing it here, for two reasons. First, Second, the fix you suggest is not currently implementable. The escaping writer #374 added is crate-private: So the bindings crate cannot route through it. Closing this properly needs openjd-rs to export the writer (or expose a Recorded in the PR description as a known gap with the upstream dependency named, so it does not live only in this thread.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correcting my earlier reply on this thread. I said closing this needs openjd-rs to export the escaping writer first. That was wrong about the remedy, though right that The Investigating it also showed the problem is wider than this one call site, in a way worth recording here. Two classes:
The worst one was not in either of our lists: One correction to your framing, for the record: this is not reachable via Still leaving this thread open: #361 covers |
||||||||||||||
| .map(|_| ()) | ||||||||||||||
| .map_err(format_string_validation_err_to_py) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bump silently breaks
make_list_err_to_py's message rewriting, because openjd-rs#373 changed the wording of the unresolved-element error in addition to thevalidate_expressionssignature the PR description covers.rust-bindings/src/expr/expr_value.rs:40-48parses the upstream headline:In 0.6.0 there was no dedicated unresolved check in
make_list, so an unresolved element fell through to the per-type element match and producedmake_list expected int element, got unresolved— which matches" element, got ", setsgot_part == "unresolved", and yields the documented reference message.0.7.0 adds an up-front check that short-circuits before the per-type match (
crates/openjd-expr/src/value.rs):strip_prefixstill succeeds, leavingrest == "concrete elements, got unresolved". That does not contain" element, got "— the text iselements,, so thesbreaks the literal — sosplit_oncereturnsNoneand the code falls through toheadline.to_string().ExprValue([42, ExprValue.unresolved(ExprType("int"))])therefore now raisesinstead of the parity message the doc comment on
make_list_err_to_pyandTestExprValueListConstructionErrors(test/openjd/expr/test_lists.py:822-847) both state is the contract:Cannot construct a list containing unresolved values. Use ExprValue.unresolved() ....The two regression tests there only assert
match="unresolved", and the raw upstream headline happens to contain that word, so both still pass — which is presumably why this went unnoticed. Worth adding theconcrete elementsspelling to the prefix handling (or matching ongot unresolvedrather than the" element, got "infix, so a future upstream rewording degrades to the parity message rather than leaking crate-internalmake_listphrasing to Python callers), and tightening the tests to assert the full expected message so the next bump catches this.