Skip to content

handle missing case properly #378

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sivukhin
Copy link

I ran govanish linter and it found one suspicious place:

2025/04/20 15:32:09 module path: /home/sivukhin/code/openai-go
2025/04/20 15:32:09 ready to compile project at path '/home/sivukhin/code/openai-go' for assembly inspection
2025/04/20 15:32:09 ready to parse assembly output
2025/04/20 15:32:10 ready to normalize assembly lines (size 76)
2025/04/20 15:32:10 built func registry: 626 entries
2025/04/20 15:32:10 ready to analyze module AST
2025/04/20 15:32:10 it seems like your code vanished from compiled binary: func=[toRespField], file=[/home/sivukhin/code/openai-go/internal/apijson/subfield.go], lines=[61-61], snippet:
	return resp.Field{}

Indeed, as IsNull() combine both explicit null and missing case, branch IsMissing() were redundant in the previous order of conditions - so compiler removed it from the code.

This looks like a bug - one possible fix is to properly treat Missing case by changing the order of conditions. But maybe there is a better (and safer - can this fix break compatibility?) fix. So feel free to close this PR.

@sivukhin sivukhin requested a review from a team as a code owner April 20, 2025 11:33
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.

1 participant