Repository: goccy/go-yaml
Pull request #572 (2024-12-05 11:42:14)

Fix unknown secondary tag behavior
resolve https://github.com/goccy/go-yaml/issues/567

codecov-commenter: :warning: Please install the !['codecov app svg image'](https://github.com/codecov/engineering-team/assets/152432831/e90313f4-9d3a-4b63-8b54-cfe14e7ec20d) to ensure uploads and comments are reliably processed by Codecov.

## [Codecov](https://app.codecov.io/gh/goccy/go-yaml/pull/572?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Masaaki+Goshima) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 77.41%. Comparing base [(`5d22eed`)](https://app.codecov.io/gh/goccy/go-yaml/commit/5d22eed00009e4cd6cf5eaf9848f77c0477d23a8?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Masaaki+Goshima) to head [(`b8cbdbc`)](https://app.codecov.io/gh/goccy/go-yaml/commit/b8cbdbce5d08c65f1fe17593e715566cc9dde1c3?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Masaaki+Goshima).
> Report is 1 commits behind head on master.

:exclamation: Your organization needs to install the [Codecov GitHub app](https://github.com/apps/codecov/installations/select_target) to enable full functionality.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master     #572      +/-   ##
==========================================
- Coverage   77.46%   77.41%   -0.05%     
==========================================
  Files          21       21              
  Lines        7482     7479       -3     
==========================================
- Hits         5796     5790       -6     
- Misses       1291     1293       +2     
- Partials      395      396       +1     
```

</details>

Patch:
diff --git a/parser/parser.go b/parser/parser.go
index dee4e25..46a1c7d 100644
--- a/parser/parser.go
+++ b/parser/parser.go
@@ -880,9 +880,6 @@ func (p *parser) parseTagValue(ctx *context, tagRawTk *token.Token, tk *Token) (
 		}
 		return p.parseSequence(ctx)
 	}
-	if strings.HasPrefix(tagRawTk.Value, "!!") {
-		return nil, errors.ErrSyntax(fmt.Sprintf("unknown secondary tag name %q specified", tagRawTk.Value), tagRawTk)
-	}
 	return p.parseToken(ctx, tk)
 }
 


Test patch:
diff --git a/parser/parser_test.go b/parser/parser_test.go
index 8d1db7b..c82adb7 100644
--- a/parser/parser_test.go
+++ b/parser/parser_test.go
@@ -70,6 +70,7 @@ func TestParser(t *testing.T) {
 		"%YAML 1.2\n---\n",
 		"a: !!binary gIGC\n",
 		"a: !!binary |\n  " + strings.Repeat("kJCQ", 17) + "kJ\n  CQ\n",
+		"v: !!foo 1",
 		"v:\n- A\n- |-\n  B\n  C\n",
 		"v:\n- A\n- >-\n  B\n  C\n",
 		"v: |-\n  0\n",
@@ -1029,14 +1030,6 @@ func TestSyntaxError(t *testing.T) {
 		source string
 		expect string
 	}{
-		{
-			`v: !!int64 2`,
-			`
-[1:4] unknown secondary tag name "!!int64" specified
->  1 | v: !!int64 2
-          ^
-`,
-		},
 		{
 			`
 a:
diff --git a/yaml_test_suite_test.go b/yaml_test_suite_test.go
index eae8f16..17ca273 100644
--- a/yaml_test_suite_test.go
+++ b/yaml_test_suite_test.go
@@ -48,6 +48,7 @@ var failureTestNames = []string{
 	"implicit-flow-mapping-key-on-one-line", // no json.
 	"invalid-comment-after-comma",
 	"invalid-comment-after-end-of-flow-sequence",
+	"invalid-comma-in-tag",
 	"invalid-tag",
 	"leading-tabs-in-double-quoted/02",
 	"leading-tabs-in-double-quoted/05",