Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested false inside true if causing result to set to null. #113

Open
Xjph opened this issue Aug 8, 2021 · 2 comments
Open

Nested false inside true if causing result to set to null. #113

Xjph opened this issue Aug 8, 2021 · 2 comments
Assignees
Labels

Comments

@Xjph
Copy link

Xjph commented Aug 8, 2021

My original where I discovered the issue was more complex, but I distilled it down to the simplest reproducible case I could find which I've placed in this fiddle: https://dotnetfiddle.net/9NzZ0O

Note the final script which produces a null result when untyped, and throws a null reference exception when a type is supplied.

@codingseb codingseb self-assigned this Aug 25, 2021
@codingseb codingseb added the bug label Aug 25, 2021
@codingseb
Copy link
Owner

Hello @Xjph, sorry for my late response.
Need to investigate a bit.
But for now you can easily manage it by returning theresult variable each times after if blocks:

--------------------------------------------
result = 0;
if (true)
{
    if (true)
    {
        result = 1;
    }
}
return result;
---------------- Result --------------------
No type:1
With type:1

--------------------------------------------
result = 0;
if (false)
{
    if (false)
    {
        result = 1;
    }
}
return result;
---------------- Result --------------------
No type:0
With type:0

--------------------------------------------
result = 0;
if (false)
{
    if (true)
    {
        result = 1;
    }
}
return result;
---------------- Result --------------------
No type:0
With type:0

--------------------------------------------
result = 0;
if (true)
{
    if (false)
    {
        result = 1;
    }
}
return result;
---------------- Result --------------------
No type:0
With type:0

or simpler : with evaluator.OptionScriptNeedSemicolonAtTheEndOfLastExpression = false;

--------------------------------------------
result = 0;
if (true)
{
    if (true)
    {
        result = 1;
    }
}
result
---------------- Result --------------------
No type:1
With type:1

--------------------------------------------
result = 0;
if (false)
{
    if (false)
    {
        result = 1;
    }
}
result
---------------- Result --------------------
No type:0
With type:0

--------------------------------------------
result = 0;
if (false)
{
    if (true)
    {
        result = 1;
    }
}
result
---------------- Result --------------------
No type:0
With type:0

--------------------------------------------
result = 0;
if (true)
{
    if (false)
    {
        result = 1;
    }
}
result
---------------- Result --------------------
No type:0
With type:0

@Xjph
Copy link
Author

Xjph commented Aug 25, 2021

The explicit return is an acceptable workaround for my use case, so certainly no need to rush on this as far as I'm concerned.

Thanks for your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants