@@ -10,10 +10,11 @@ import (
1010 "github.com/hashicorp/hcl/v2/gohcl"
1111
1212 "github.com/google/go-cmp/cmp"
13+ "github.com/zclconf/go-cty/cty"
14+
1315 "github.com/hashicorp/hcl/v2"
1416 "github.com/hashicorp/hcl/v2/hclsyntax"
1517 "github.com/hashicorp/hcl/v2/json"
16- "github.com/zclconf/go-cty/cty"
1718)
1819
1920var (
@@ -700,6 +701,30 @@ func TestGetTypeDefaults(t *testing.T) {
700701 nil ,
701702 `Optional attribute modifier expects at most two arguments: the attribute type, and a default value.` ,
702703 },
704+
705+ // Duplicate arguments.
706+ {
707+ `map(object({operations=optional(list(string), []),type=optional(string, "ABC"),type=optional(number)}))` ,
708+ & Defaults {
709+ Type : cty .Map (cty .ObjectWithOptionalAttrs (map [string ]cty.Type {
710+ "operations" : cty .List (cty .String ),
711+ "type" : cty .String ,
712+ }, []string {"operations" , "type" })),
713+ Children : map [string ]* Defaults {
714+ "" : {
715+ Type : cty .ObjectWithOptionalAttrs (map [string ]cty.Type {
716+ "operations" : cty .List (cty .String ),
717+ "type" : cty .String ,
718+ }, []string {"operations" , "type" }),
719+ DefaultValues : map [string ]cty.Value {
720+ "operations" : cty .ListValEmpty (cty .String ),
721+ "type" : cty .StringVal ("ABC" ),
722+ },
723+ },
724+ },
725+ },
726+ "Object constructor map keys must be unique." ,
727+ },
703728 }
704729
705730 for _ , test := range tests {
0 commit comments