Page 1 of 1

Evaluation bug?

Posted: Wed Aug 15, 2018 9:14 am
by wx3
I'm seeing what looks like a condition evaluation bug. A simple example:

Code: Select all

False() and True()
Where False() and True() are defined in my Unity script as:

Code: Select all

    public bool True()
    {
        Debug.Log("This returns true.");
        return true;
    }

    public bool False()
    {
        Debug.Log("This returns false.");
        return false;
    }
When the condition is evaluated, I see "This returns false." followed by "This returns trues."

LUA is supposed to support short-circuit evaluation, so the correct behavior should be that True() is never evaluated. (My actual use case is combining an array bounds check with an array look up to avoid errors.)

Is this a bug or am I missing something?

Re: Evaluation bug?

Posted: Wed Aug 15, 2018 9:57 am
by Tony Li
Hi,

It appears that LuaInterpreter, the native C# Lua implementation used in the Dialogue System, doesn't do short-circuit evaluation. I'll see if I can fix this in version 2.0.4.

Re: Evaluation bug?

Posted: Wed Aug 15, 2018 10:48 am
by wx3
Thanks for the quick response. I'm probably going to stick with 1.x series, but I'm sure I can find a workaround.

Re: Evaluation bug?

Posted: Wed Aug 15, 2018 11:41 am
by Tony Li
I just implemented the fix for 2.x. It'll be in 2.0.4.

What version of Unity are you using? I'll send you a fix for 1.x. The fix will also be in version 1.8.6, which won't come out for a while. Version 1.x is only getting bug fixes. Currently the only fix is this one. If no other bug reports come in, I'll build and release 1.8.6 at the end of September.

Re: Evaluation bug?

Posted: Wed Aug 15, 2018 4:42 pm
by wx3
2017.3.1f1