Hello!
This is very severe issue which is prohibiting usage of parserng in deployment.
If statistic function is given eg sum(5,4)
it works, when it is given sum(5)
it works.
When it is given sum(1+1,2+2)
it works. However when it is given sum(1+1)
it fails.
Notable is, that eg sum(sin(5))
works too. However sum(sin(5)+(sin(5))
don't.
All my inputs for parserNG are generated, so it took some time to see why some of the first calls fails. Yes first, as in in first call they have just one
argument. Also not all equations have expression in first argument..
The issue is reproduced here: #23
Possible workaround suggested at: #24
The issue is not related to #22 ; was jsut accidently hit there.
The fix would be harder. It seems coma
is somewhere handled wrongly. I tried, but but failed. IMHO, parserNG do nto have enough juint coverage to actually affrod proepr fix. But you know internals better.
The internal isse is visibel like this:
sum(1,2)
is proeperly parsed and sent to sum
impelmetnation as two arguments as 1,2
sum(1+1,2+2)
is proeperly parsed, evaluated and sent to sum
impelmetnation as two arguments as 2,4
however sum(1+1)
is wronlgy parsed and not evaluated, and send to sum
implemetnation as three arguments 1,+,1
@gbenroscience @gbenrojiboye can you fix it? If not, can you please participate on workaround? On short run, the workaround is just: https://github.com/gbenroscience/ParserNG/pull/24/files#diff-7592ec3fb1f62c29d86d7c8c826fc5a684c85caee27fc35b7b6c3c5628bc47e1R101
Which can be then reused in any existing statistic function, or in any override of statistic function (see 0c7177e)
The workaround is checking the input on function. If it is all numbers, then it is passed in.
If it is not all numbers, then it is joined first and evaluated. Then result is passed in.
Unless the issue is resolved "properly" all the hardcoded statistic function can reuse above workaround.
There is acompanying issue, when hardcoded not-statistic functions eg sin or cos can actually take several argument, and missinterpret them:
sin(5)
ok. sin(5+5
) ok. However sin(5,5)
is accepted, and evaluated as sin((5)(5))
whis is sin(5*5)
which is wrong.
This issue is not fatal, and as blocking as first issue,
Still the fix for both issues seems to go deep into parsetr. On longest run the statistic an non statistc functions should be aligned.
The issue is also reproduced here: #23
and also workaround suggested at: #24 by moving non statistic sin to statistic, and properly throwing exception if more then one argument is set.
@gbenrojiboye @gbenroscience Please, look into the PRs or suggest better solution, otherwise we will need to live only in the fork of ParserNG instead of contributing back.
Important highlight: @gbenrojiboye @gbenroscience this issue is not caused by any recent commits. I had tracked it down to first public commit on this repo