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:(ast) SortKeys(true) panic when not loaded-all #603

Merged
merged 2 commits into from Feb 28, 2024
Merged

Conversation

AsterDY
Copy link
Collaborator

@AsterDY AsterDY commented Feb 28, 2024

Reproduce Code

func TestNodeSortKeys2(t *testing.T) {
    root, err := NewSearcher(_TwitterJson).GetByPath()
    if err != nil {
        t.Fatal(err)
    }
    t.Run("single", func(t *testing.T) {
        r := root.Get("statuses")
        if r.Check() != nil {
            t.Fatal(r.Error())
        }
        require.NoError(t, root.SortKeys(false))
    })
    t.Run("recurse", func(t *testing.T) {
        require.NoError(t, root.SortKeys(true))
    })
}
--  runtime error: invalid memory address or nil pointer dereference 

Reason

sortKey() use unsafeMap() at the beginning , which doesn't considerV_RAW type nodes

@AsterDY AsterDY merged commit 3739ffe into main Feb 28, 2024
33 checks passed
@AsterDY AsterDY deleted the fix/ast_sort branch February 28, 2024 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.

None yet

2 participants