Skip to content

Commit fdf9a0a

Browse files
reid-spencerclaude
andcommitted
Emit OnMessageClause as its message reference, not a quoted identifier
An OnMessageClause's id is a synthetic "keyword path" string (e.g. "command Go"). After Identifier.format began single-quoting non-bare names, openDef rendered the clause as `on 'command Go'`, which does not re-parse. Emit the clause's message reference (msg.format) instead, which is the round-trippable source form; all other synthetic ids are bare literals and unaffected. Fixes JsonInputTest reference-carrying-statements round-trip on JVM, JS, and Native. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 5d00535 commit fdf9a0a

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

passes/shared/src/main/scala/com/ossuminc/riddl/passes/prettify/RiddlFileEmitter.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ case class RiddlFileEmitter(url: URL)(using PlatformContext) extends FileBuilder
3737
definition: Definition,
3838
withBrace: Boolean = true
3939
): this.type = {
40-
addIndent(s"${keyword(definition)} ${definition.id.format} is ")
40+
// An OnMessageClause's id is a synthetic "keyword path" string (e.g.
41+
// "command Go"); emit the message reference itself, which is the
42+
// round-trippable source form, rather than quoting it as an identifier.
43+
val name = definition match
44+
case omc: OnMessageClause => omc.msg.format
45+
case _ => definition.id.format
46+
addIndent(s"${keyword(definition)} $name is ")
4147
if withBrace then
4248
if definition.isEmpty then add("{ ??? }").nl
4349
else add("{").nl.incr

0 commit comments

Comments
 (0)