[SR-Users] $null + 0 is not int

Daniel-Constantin Mierla miconda at gmail.com
Mon Dec 2 08:58:44 CET 2019


It was like this from the beginning, there is a base string type for
variables by default.

If people want, then we can reconsider when doing a major
refactoring/adjustment to the native interpreter, probably for Kamailio
6.0, as there were some discussions during the last Kamailio Developers
Meeting in Dusseldorf and informed to mailing lists.

However, that can result in no-operations with $null values, like it
happens now in Lua or Python -- if you want to print or use in
expressions NULL, you get an exception, stopping execution of the script
for the respective SIP message. That is the reason KEMI has
KSR.pv.gete() to return empty string when the value is $null, otherwise
the external scripting interpreters throw errors/exceptions when using
NULL in expressions.

I still thing that having a loose handling of $null is better that
string evaluation to "nothing" -- it can result in a lot of IF
conditions to evaluate if a variable can be used in an expression or log
or other functions parameters. But again, it can be discussed and
reconsidered.

Cheers,
Daniel

On 02.12.19 03:50, Juha Heinanen wrote:
> Thanks for the tip. 0 + $null is int. The bug is that $null should be nothing, not an empty string.
>
> -- Juha

-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio World Conference - April 27-29, 2020, in Berlin -- www.kamailioworld.com




More information about the sr-users mailing list