@@ -203,7 +203,7 @@ func isTomlArrayOfTables(seq *CandidateNode) bool {
203203 return false
204204 }
205205 for _ , it := range seq .Content {
206- if it .Kind != MappingNode {
206+ if it .Kind != MappingNode || it . EncodeHint == EncodeHintInline {
207207 return false
208208 }
209209 }
@@ -535,7 +535,7 @@ func (te *tomlEncoder) encodeSeparateMapping(w io.Writer, path []string, m *Cand
535535
536536// encodeMappingBodyWithPath encodes attributes and nested arrays of tables using full dotted path context
537537func (te * tomlEncoder ) encodeMappingBodyWithPath (w io.Writer , path []string , m * CandidateNode ) error {
538- // First, attributes (scalars and non-map arrays)
538+ // First, attributes (scalars, inline mappings, and non-map arrays)
539539 for i := 0 ; i < len (m .Content ); i += 2 {
540540 k := m .Content [i ].Value
541541 v := m .Content [i + 1 ]
@@ -544,6 +544,12 @@ func (te *tomlEncoder) encodeMappingBodyWithPath(w io.Writer, path []string, m *
544544 if err := te .writeAttribute (w , k , v ); err != nil {
545545 return err
546546 }
547+ case MappingNode :
548+ if v .EncodeHint == EncodeHintInline {
549+ if err := te .writeInlineTableAttribute (w , k , v ); err != nil {
550+ return err
551+ }
552+ }
547553 case SequenceNode :
548554 if ! isTomlArrayOfTables (v ) {
549555 if err := te .writeArrayAttribute (w , k , v ); err != nil {
@@ -572,21 +578,15 @@ func (te *tomlEncoder) encodeMappingBodyWithPath(w io.Writer, path []string, m *
572578 }
573579 }
574580
575- // Finally, child mappings: inline-hint ones become inline table attributes,
581+ // Finally, child mappings: inline-hint ones were emitted above as attributes,
576582 // while all others are emitted as separate sub-table sections.
577583 for i := 0 ; i < len (m .Content ); i += 2 {
578584 k := m .Content [i ].Value
579585 v := m .Content [i + 1 ]
580- if v .Kind == MappingNode {
581- if v .EncodeHint == EncodeHintInline {
582- if err := te .writeInlineTableAttribute (w , k , v ); err != nil {
583- return err
584- }
585- } else {
586- subPath := append (append ([]string {}, path ... ), k )
587- if err := te .encodeSeparateMapping (w , subPath , v ); err != nil {
588- return err
589- }
586+ if v .Kind == MappingNode && v .EncodeHint != EncodeHintInline {
587+ subPath := append (append ([]string {}, path ... ), k )
588+ if err := te .encodeSeparateMapping (w , subPath , v ); err != nil {
589+ return err
590590 }
591591 }
592592 }
0 commit comments