Skip to content

intent: a posts: set: constant renders as a Java string literal (#7246) - #7268

Merged
delchev merged 1 commit into
masterfrom
issue-7246-posts-set-string-literal
Sep 10, 2026
Merged

intent: a posts: set: constant renders as a Java string literal (#7246)#7268
delchev merged 1 commit into
masterfrom
issue-7246-posts-set-string-literal

Conversation

@delchev

@delchev delchev commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #7246

The defect

GlueIntentGenerator.postSetExpr tested a set: value against "[^"]*" for its string branch - it only fired while the value still carried its double quotes, which YAML strips long before the renderer sees it. An authored

set:
  Note: issued

reached the renderer as issued, missed every branch and fell through the final pass-through, so the template emitted

row.Note = issued;

and the whole generated module stopped compiling. PostIntent's own javadoc documented "a quoted string" as a supported form, and GluePostsTest asserted the item / negation / integer / source forms only, so nothing caught it.

The change

The value vocabulary moves into one place, PostSetSupport, shared by the renderer and a new parse-time refusal so the two cannot drift:

The refusal is the point of the third case. Rendering Receipt.Store as the string "Receipt.Store" would put the text of the path into the ledger cell instead of the value it names - silent in exactly the way passing it through was, and worse than a compile error. Refusing before anything is written is the honest outcome, and an author who really means that text quotes it.

The PostIntent example is corrected with it: it showed Store: Receipt.Store and GoodsReceipt: Receipt.Id, neither of which the renderer ever supported (the back-reference named by idempotentBy is written by the generated handler, not authored).

Tests

GluePostsTest gains the constant to the existing descriptor assertion (Note: issued -> "issued"), plus the escaping of a quote / backslash, the non-text forms, and the parse-time refusal naming the rule and the field. Full engine-intent suite green (1190 tests); formatter:validate and the release-profile javadoc clean on the module.

🤖 Generated with Claude Code

`GlueIntentGenerator.postSetExpr` recognised a string value only while it
still carried its double quotes, which YAML strips long before the renderer
sees it. An authored `Note: issued` therefore missed every branch and fell
through the pass-through, emitting `row.Note = issued;` - a bare identifier
that stops the whole generated module compiling. The construct's own javadoc
documented "a quoted string" as a supported form and `GluePostsTest` covered
the item / negation / integer / source forms only, so nothing caught it.

The value vocabulary now lives in one place, `PostSetSupport`, shared by the
renderer and a new parse-time refusal so the two cannot drift:

- a plain constant renders as an ESCAPED Java string literal (the #7154 /
  #7241 family - a value carrying a quote or a backslash cannot end the
  literal it is written into);
- a number, `true` / `false` / `null`, and a value the author quoted
  explicitly keep their non-text reading;
- a value that reads as an EXPRESSION the renderer cannot compile - a dotted
  path off anything but `item` / `source`, or a negation of anything but a
  per-item copy - is refused at parse time, naming the rule and the field.

The refusal is the point of the third case: rendering `Receipt.Store` as the
string "Receipt.Store" would put the text of the path into the ledger cell
instead of the value it names, which is silent in exactly the way passing it
through was. An author who really means that text quotes it.

The `PostIntent` example is corrected with it: it showed `Store: Receipt.Store`
and `GoodsReceipt: Receipt.Id`, neither of which the renderer ever supported
(the back-reference is written by the generated handler, not authored).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

intent: a string value in a posts: set: renders as a bare Java identifier - the generated post handler does not compile

1 participant