diff --git a/parser/parser.go b/parser/parser.go index 959e366..08f9dfe 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -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: @@ -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: @@ -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 } diff --git a/yaml_test_suite_test.go b/yaml_test_suite_test.go index 73cb459..fbd1525 100644 --- a/yaml_test_suite_test.go +++ b/yaml_test_suite_test.go @@ -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.