Skip to content

Commit d04a160

Browse files
authored
Use InvalidArgError() to dsl.Type() more (#3635)
1 parent 4e52a99 commit d04a160

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

dsl/user_type.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func Type(name string, args ...any) expr.UserType {
8585
if len(args) == 2 {
8686
d, ok := args[1].(func())
8787
if !ok {
88-
eval.ReportError("third argument must be a function")
88+
eval.InvalidArgError("function", args[1])
8989
return nil
9090
}
9191
fn = d

eval/eval_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func TestInvalidArgError(t *testing.T) {
2929
"Security": {func() { Security(1) }, "cannot use 1 (type int) as type security scheme or security scheme name"},
3030
"Security (typed nil)": {func() { Security((*expr.SchemeExpr)(nil)) }, "cannot use (*expr.SchemeExpr)(nil) (type *expr.SchemeExpr) as type security scheme"},
3131
"Type": {func() { Type("name", 1) }, "cannot use 1 (type int) as type type or function"},
32+
"Type (DataType)": {func() { Type("name", String, 1) }, "cannot use 1 (type int) as type function"},
3233
}
3334
for name, tc := range dsls {
3435
t.Run(name, func(t *testing.T) {

0 commit comments

Comments
 (0)