Skip to content

Commit

Permalink
fix flow-mapping-edge-cases (#621)
Browse files Browse the repository at this point in the history
  • Loading branch information
goccy authored Jan 18, 2025
1 parent 3b6beba commit f739772
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions scanner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,12 @@ func (s *Scanner) scanMapDelim(ctx *Context) (bool, error) {
// like http://
return false, nil
}
if s.startedFlowMapNum > 0 {
tk := ctx.lastToken()
if tk != nil && tk.Type == token.MappingValueType {
return false, nil
}
}

if strings.HasPrefix(strings.TrimPrefix(string(ctx.obuf), " "), "\t") && !strings.HasPrefix(string(ctx.buf), "\t") {
invalidTk := token.Invalid("tab character cannot use as a map key directly", string(ctx.obuf), s.pos())
Expand Down
3 changes: 1 addition & 2 deletions yaml_test_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var failureTestNames = []string{
"empty-keys-in-block-and-flow-mapping", // no json.
"empty-lines-at-end-of-document", // no json.
"flow-mapping-separate-values", // no json.
"flow-sequence-in-flow-mapping", // no json.
"implicit-flow-mapping-key-on-one-line", // no json.
"mapping-key-and-flow-sequence-item-anchors", // no json.
"nested-implicit-complex-keys", // no json.
Expand All @@ -46,10 +47,8 @@ var failureTestNames = []string{
"comment-without-whitespace-after-doublequoted-scalar",
"construct-binary",
"dash-in-flow-sequence",
"flow-sequence-in-flow-mapping",
"flow-collections-over-many-lines/01",
"flow-mapping-colon-on-line-after-key/02",
"flow-mapping-edge-cases",
"invalid-comment-after-comma",
"invalid-comment-after-end-of-flow-sequence",
"invalid-comma-in-tag",
Expand Down

0 comments on commit f739772

Please sign in to comment.