On Nov 10, 2009 at 12:49, Juha Heinanen <jh(a)tutpro.com> wrote:
Andrei Pelinescu-Onciul writes:
We could generate an error message, but only at
runtime (because we
don't know the type of $var(tmp) at script compile time).
andrei,
run-time would be great. current no-error implementation results in
many non-working scripts, where people wonder what is wrong with them.
Latest sr_3.0 should have them, as warnings, e.g.:
WARNING: <core> [rvalue.c:987]: automatic string to int conversion for
"avp_test1" failed
WARNING: <core> [rvalue.c:1838]: rval expression conversion to int
failed (40,12-40,25)
^^^^^^^^^^^ expression position in the config.
The behaviour can now be controlled by defines.
From rvalue.c:
* RV_STR2INT_VERBOSE_ERR - if a
string conversion to int fails, log (L_WARN)
* the string that caused it (only the string, not
* the expression position).
* RV_STR2INT_ERR - if a string conversion to int fails, don't ignore
* the error (return error).
* RVAL_GET_INT_ERR_WARN - if a conversion to int fails, log a warning with
* the expression position.
* Depends on RV_STR2INT_ERR.
* RVAL_GET_INT_ERR_IGN - if a conversion to int fails, ignore the error
* (the result will be 0). Can be combined with
* RVAL_GET_INT_ERR_WARN.
* Depends on RV_STR2INT_ERR.
By default all of them are on/defined.
This is quite a late change (for sr_3.0), but if something goes wrong it
can easily be reverted by commenting all of the 4 defines at the top of
rvalue.c.
Andrei