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

FLAG_IGNORE_SLICE_ORDER - panic: runtime error: hash of unhashable type map[string]interface {} #60

Open
sschulz-t opened this issue Sep 27, 2023 · 0 comments

Comments

@sschulz-t
Copy link

Please see the example 5) from this playground: https://go.dev/play/p/M-VZFkXte9T

With FLAG_IGNORE_SLICE_ORDER set, it causes a panic.

It happens at:

func (c *cmp) equals(a, b reflect.Value, level int) {
...
am[a.Index(i).Interface()] += 1
...
}

where the code tries to use the map[string]interface{} as a key when the child is a slice.

When reading the comments in the code:

	// FLAG_IGNORE_SLICE_ORDER causes Equal to ignore slice order so that
	// []int{1, 2} and []int{2, 1} are equal. Only slices of primitive scalars
	// like numbers and strings are supported. Slices of complex types,
	// like []T where T is a struct, are undefined because Equal does not
	// recurse into the slice value when this flag is enabled.

This states it is unsupported to use it with this type of data. I was wondering if it is possible to add this feature in the future.
At least this ticket could save others some time when they do a web search for the cause of the error and did not read the documentation ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant