Closed deosjr closed 3 years ago
Good catch. Yes deriveSort should be made to be able to generate this without an error. Thank you for reporting. I clearly didn't test type aliases enough :)
I don't think I'll be diving into this deep enough to fix it. Did create a few test cases to illustrate, which I include here
type stringalias string
func TestSortedMapKeysTypeAliasKey(t *testing.T) {
var m map[stringalias]string
m = random(m).(map[stringalias]string)
keys := deriveSortedAlias(deriveKeysForMapAliasToString(m))
This test case will fail because of the stated issue: deriveSortedAlias is never generated.
The analogous TestSortedMapKeysTypeAliasValue
does succeed but is currently missing from the test suite.
func TestSortedMapKeysTypeAliasInScope(t *testing.T) {
type stringalias string
var m map[string]stringalias
m = random(m).(map[string]stringalias)
keys := deriveSorted(deriveKeysForMapStringToAlias(m))
This test I made by mistake, and fails for a different reason.
deriveSorted
is generated, but the alias is only defined in scope of the test.
Running goderive
therefore succeeds but the program won't compile.
No problem. The report is already very helpful, thank you :) Especially providing test cases, is even more useful. Thanks for all your help here.
Consider the following program
Running
goderive
runs fine, but subsequently the program fails to compile, with the following error:deriveSorted
has been generated as:and it is sort.Ints that is throwing the error