Evaluation bug?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
wx3
Posts: 10
Joined: Mon Aug 08, 2016 6:14 pm

Evaluation bug?

Post 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?
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Evaluation bug?

Post 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.
wx3
Posts: 10
Joined: Mon Aug 08, 2016 6:14 pm

Re: Evaluation bug?

Post 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.
User avatar
Tony Li
Posts: 21925
Joined: Thu Jul 18, 2013 1:27 pm

Re: Evaluation bug?

Post 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.
wx3
Posts: 10
Joined: Mon Aug 08, 2016 6:14 pm

Re: Evaluation bug?

Post by wx3 »

2017.3.1f1
Post Reply