8000 Support implicit null by goccy · Pull Request #727 · goccy/go-yaml · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support implicit null #727

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

8000
Merged
merged 1 commit into from
May 8, 2025
Merged

Support implicit null #727

merged 1 commit into from
May 8, 2025

Conversation

goccy
Copy link
Owner
@goccy goccy commented May 8, 2025

resolve #710

Add ImplicitNullType as a token type.
ImplicitNullType is used during the parser phase when inserting a null token. If ast.NullNode holds this token, the "null" string will be omitted when converted to a string. This enables reversible conversion of implicit nulls.

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 73.33333% with 4 lines in your changes missing coverage. Please review.

Project coverage is 77.94%. Comparing base (e61dcd0) to head (3491b9f).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #727      +/-   ##
==========================================
- Coverage   77.95%   77.94%   -0.02%     
==========================================
  Files          22       22              
  Lines        7993     7998       +5     
==========================================
+ Hits         6231     6234       +3     
- Misses       1347     1349       +2     
  Partials      415      415              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@goccy goccy requested a review from Copilot May 8, 2025 14:19
Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces an ImplicitNullType token to enable reversible conversion of implicit nulls by omitting the "null" string during output.

  • Added a new ImplicitNullType constant and its corresponding string representation.
  • Updated parser, context, and AST methods to process implicit null tokens.
  • Modified tests to account for the new implicit null behavior.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
token/token.go Adds a new constant ImplicitNullType and its string mapping.
parser/token.go Includes ImplicitNullType in scalar type handling.
parser/parser.go Replaces createNullToken calls with createImplicitNullToken in various parse methods.
parser/context.go Refactors token creation by renaming createNullToken to createImplicitNullToken.
ast/ast.go Updates NullNode and AnchorNode string representations to distinguish implicit nulls.
parser_test.go Adjusts test cases to align with the reversible conversion of implicit null values.

@@ -627,6 +627,12 @@ func (n *NullNode) GetValue() interface{} {

// String returns `null` text
func (n *NullNode) String() string {
if n.Token.Type == token.ImplicitNullType {
Copy link
Preview
Copilot AI May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8000

Consider adding a clarifying comment here to explain why an implicit null token returns its comment string (if available) rather than a fixed 'null' value. This will help maintainers understand the reversible conversion behavior for implicit null tokens.

Copilot uses AI. Check for mistakes.

@goccy goccy merged commit 500180b into master May 8, 2025
25 checks passed
@goccy goccy deleted the support-implicit-null branch May 8, 2025 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[for yq] Blank value turns into null string
2 participants
0