Fix panic when accessing a map with a key type that's not comparable with map index #177
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is being done in this PR?
Fixes issue#176
What are the main choices made to get to this solution?
If the map key is not of
interface{}
type then the index and map key type should be the same. If not then an error will be returned"line 1: cannot use first (string constant) as int value in map index"
List the manual test cases you've covered before sending this PR:
Created two new tests under
hashes_test.go
.Test_Render_Hash_Key_Interface
: This test should pass as the map key type is of a typeinterface{}
Test_Render_Hash_Key_Int_With_String_Index
: This test should return an error because the map key type is int and accessing it with a string.