Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/pulumiyaml/analyser.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,9 @@ func typePropertyAccess(ctx *evalContext, root schema.Type,
if len(accessors) == 0 {
return root
}
if root == schema.AnyType {
return schema.AnyType
}
if root, ok := root.(*schema.UnionType); ok {
var possibilities OrderedTypeSet
errs := []*notAssignable{}
Expand Down
14 changes: 12 additions & 2 deletions pkg/pulumiyaml/analyser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,24 @@ func TestTypePropertyAccess(t *testing.T) {
errMsg string
}{
{
root: &schema.MapType{ElementType: &schema.ArrayType{ElementType: schema.AnyType}},
root: &schema.MapType{ElementType: &schema.ArrayType{ElementType: schema.IntType}},
list: []ast.PropertyAccessor{
&ast.PropertySubscript{Index: "foo"},
&ast.PropertySubscript{Index: 7},
&ast.PropertySubscript{Index: "foo"},
},
expectedType: "Invalid",
errMsg: `Cannot index into 'start["foo"][7]' (type any):Index property access is only allowed on Maps and Lists`,
errMsg: `Cannot index into 'start["foo"][7]' (type integer):Index property access is only allowed on Maps and Lists`,
},
{
// Once in any Any type, all property access is valid:
root: schema.AnyType,
list: []ast.PropertyAccessor{
&ast.PropertySubscript{Index: "foo"},
&ast.PropertySubscript{Index: 7},
&ast.PropertySubscript{Index: "foo"},
},
expectedType: "any",
},
{
root: &schema.ResourceType{
Expand Down