diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2020-01-07 01:24:30 +0100 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2020-01-07 01:24:30 +0100 |
commit | ef8c45749c82e246d477ea4d7f749668a9c7e9ee (patch) | |
tree | eee628e31aed68a622dff74017314a9c3fd07ca0 /filter | |
parent | cc75b3e1dc4a7440479d6f4d73e7e1b9ba65332f (diff) |
Filter: Fix typecheck for AND/OR.
Do not apply dynamic type check for second argument of AND/OR, as it is
not evaluated immediately like regular argument would be.
Thanks to Mikael for the bugreport.
Diffstat (limited to 'filter')
-rw-r--r-- | filter/decl.m4 | 7 | ||||
-rw-r--r-- | filter/f-inst.c | 4 |
2 files changed, 8 insertions, 3 deletions
diff --git a/filter/decl.m4 b/filter/decl.m4 index a78450a3..efecb9a5 100644 --- a/filter/decl.m4 +++ b/filter/decl.m4 @@ -161,11 +161,16 @@ FID_HIC(,[[ # Some arguments need to check their type. After that, ARG_ANY is called. m4_define(ARG, `ARG_ANY($1) ARG_TYPE($1,$2)') -m4_define(ARG_TYPE, ` +m4_define(ARG_TYPE, `ARG_TYPE_STATIC($1,$2) ARG_TYPE_DYNAMIC($1,$2)') + +m4_define(ARG_TYPE_STATIC, ` FID_NEW_BODY()m4_dnl if (f$1->type && (f$1->type != ($2)) && !f_const_promotion(f$1, ($2))) cf_error("Argument $1 of %s must be of type %s, got type %s", f_instruction_name(what->fi_code), f_type_name($2), f_type_name(f$1->type)); +FID_INTERPRET_BODY()') + +m4_define(ARG_TYPE_DYNAMIC, ` FID_INTERPRET_EXEC()m4_dnl if (v$1.type != ($2)) runtime("Argument $1 of %s must be of type %s, got type %s", diff --git a/filter/f-inst.c b/filter/f-inst.c index 51a35350..4b3c627b 100644 --- a/filter/f-inst.c +++ b/filter/f-inst.c @@ -226,7 +226,7 @@ } INST(FI_AND, 1, 1) { ARG(1,T_BOOL); - ARG_TYPE(2,T_BOOL); + ARG_TYPE_STATIC(2,T_BOOL); RESULT_TYPE(T_BOOL); if (v1.val.i) @@ -236,7 +236,7 @@ } INST(FI_OR, 1, 1) { ARG(1,T_BOOL); - ARG_TYPE(2,T_BOOL); + ARG_TYPE_STATIC(2,T_BOOL); RESULT_TYPE(T_BOOL); if (!v1.val.i) |