Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scalar-value-with-two-anchors #581

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading