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 json parsing bug #101

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sivukhin
Copy link

@sivukhin sivukhin commented Dec 24, 2023

I ran govanish linter (it still in the WIP phase) against gval repo and it found that one error handling branch were eliminated by compiler:

2023/12/24 21:05:32 it seems like your code vanished from compiled binary: func=[parseJSONObject], file=[/home/sivukhin/code/gval/parse.go], line=[320], snippet:
	return nil, p.Expected("object", ':')
if p.Scan() != ':' {
	if err != nil {
		return nil, p.Expected("object", ':')
	}
}

Indeed, errcheck in this case is useless and actually prevent parsing from correct behaviour: rejecting invalid JSON structure.

This PR remove err check and always return error if p.Scan() return incorrect symbol.

Also, test Invalid json key:value structure for incorrect JSON structure were added (it were red before fix and became green after)

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.

None yet

1 participant