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 typo causing a panic in tuple unification #126

Merged
merged 1 commit into from Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions cty/convert/unify.go
Expand Up @@ -447,7 +447,6 @@ func unifyTupleTypes(types []cty.Type, unsafe bool, hasDynamic bool) (cty.Type,
conversions[i] = GetConversion(ty, retTy)
}
if conversions[i] == nil {
// Shouldn't be reachable, since we were able to unify
return unifyTupleTypesToList(types, unsafe)
}
}
Expand Down Expand Up @@ -483,8 +482,8 @@ func unifyTupleTypesToList(types []cty.Type, unsafe bool) (cty.Type, []Conversio
conversions[i] = GetConversion(ty, retTy)
}
if conversions[i] == nil {
// Shouldn't be reachable, since we were able to unify
return unifyObjectTypesToMap(types, unsafe)
// no conversion was found
return cty.NilType, nil
}
}
return retTy, conversions
Expand Down
17 changes: 17 additions & 0 deletions cty/convert/unify_test.go
Expand Up @@ -163,6 +163,23 @@ func TestUnify(t *testing.T) {
cty.List(cty.Map(cty.String)),
[]bool{true, true},
},
{
// The second tuple value could be anything, so we can't unify
// these as a list.
// FIXME: While a unification is possible, we get a NilType for
// now until we can handle more complex recursive unification.
[]cty.Type{
cty.Tuple([]cty.Type{
cty.Object(map[string]cty.Type{
"a": cty.String,
}),
cty.DynamicPseudoType,
}),
cty.List(cty.DynamicPseudoType),
},
cty.NilType,
nil,
},
{
// unifies to the same result as above, since the only difference
// is the addition of a list
Expand Down