Summary
TemplateStringRule.serialize strips the " delimiters whenever
strip_string_quotes is set. That rule only ever appears inside a template
directive, where the text is expression source -- so the delimiters it removes
are a string literal's, not the template's.
Reproduction
hcl2.loads('a = "%{ if x == \\"y\\" }t%{ endif }"\n',
serialization_options=SerializationOptions(strip_string_quotes=True))["a"]
# '%{ if x == y }t%{ endif }'
The literal "y" has become a reference to y: a different expression, not a
different spelling of the same one. TemplateStringRule.serialize is
hcl2/rules/strings.py:269 at v8.1.3. The source form is correct; only the
value form is affected.
Same root cause as #E above -- a rule inside expression source treating it as
literal text -- but a different rule, so it is filed separately.
This issue, and the investigation behind it, were produced by an AI assistant (Claude) working on behalf of the author. Please review with that provenance in mind.
Summary
TemplateStringRule.serializestrips the"delimiters wheneverstrip_string_quotesis set. That rule only ever appears inside a templatedirective, where the text is expression source -- so the delimiters it removes
are a string literal's, not the template's.
Reproduction
The literal
"y"has become a reference toy: a different expression, not adifferent spelling of the same one.
TemplateStringRule.serializeishcl2/rules/strings.py:269atv8.1.3. The source form is correct; only thevalue form is affected.
Same root cause as #E above -- a rule inside expression source treating it as
literal text -- but a different rule, so it is filed separately.
This issue, and the investigation behind it, were produced by an AI assistant (Claude) working on behalf of the author. Please review with that provenance in mind.