Skip to content

Commit

Permalink
fix scalar-value-with-two-anchors
Browse files Browse the repository at this point in the history
  • Loading branch information
goccy committed Dec 9, 2024
1 parent 6100d5f commit d4be04a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 9 additions & 0 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ func (p *parser) parseToken(ctx *context, tk *Token) (ast.Node, error) {
if err != nil {
return nil, err
}
if _, ok := value.(*ast.AnchorNode); ok {
return nil, errors.ErrSyntax("anchors cannot be used consecutively", value.GetToken())
}
anchor.Value = value
return anchor, nil
case TokenGroupAlias:
Expand Down Expand Up @@ -283,6 +286,9 @@ func (p *parser) parseScalarValue(ctx *context, tk *Token) (ast.ScalarNode, erro
if err != nil {
return nil, err
}
if _, ok := value.(*ast.AnchorNode); ok {
return nil, errors.ErrSyntax("anchors cannot be used consecutively", value.GetToken())
}
anchor.Value = value
return anchor, nil
case TokenGroupAlias:
Expand Down Expand Up @@ -797,6 +803,9 @@ func (p *parser) parseAnchor(ctx *context, g *TokenGroup) (*ast.AnchorNode, erro
if err != nil {
return nil, err
}
if _, ok := value.(*ast.AnchorNode); ok {
return nil, errors.ErrSyntax("anchors cannot be used consecutively", value.GetToken())
}
anchor.Value = value
return anchor, nil
}
Expand Down
1 change: 0 additions & 1 deletion yaml_test_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ var failureTestNames = []string{
"plain-dashes-in-flow-sequence",
"question-mark-edge-cases/00", // no json.
"question-mark-edge-cases/01", // no json.
"scalar-value-with-two-anchors", // pass yamlv3.
"single-character-streams/01", // no json.
"single-pair-implicit-entries", // no json.
"spec-example-2-11-mapping-between-sequences", // no json.
Expand Down

0 comments on commit d4be04a

Please sign in to comment.