Skip to content

Commit 2541a82

Browse files
committed
Fix default type of map created in expr
1 parent 9c096db commit 2541a82

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

checker/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var (
1313
floatType = reflect.TypeOf(float64(0))
1414
stringType = reflect.TypeOf("")
1515
arrayType = reflect.TypeOf([]interface{}{})
16-
mapType = reflect.TypeOf(map[interface{}]interface{}{})
16+
mapType = reflect.TypeOf(map[string]interface{}{})
1717
interfaceType = reflect.TypeOf(new(interface{})).Elem()
1818
)
1919

expr_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,10 @@ func TestExpr(t *testing.T) {
637637
`1 + 2 + Three`,
638638
6,
639639
},
640+
{
641+
`MapArg({foo: "bar"})`,
642+
"bar",
643+
},
640644
}
641645

642646
for _, tt := range tests {
@@ -703,6 +707,10 @@ func (*mockEnv) Duration(s string) time.Duration {
703707
return d
704708
}
705709

710+
func (*mockEnv) MapArg(m map[string]interface{}) string {
711+
return m["foo"].(string)
712+
}
713+
706714
type ticket struct {
707715
Price int
708716
}

0 commit comments

Comments
 (0)