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

The condition of the 'if' method returns a number (xFunc.maths 3.7.1) #301

Closed
KevinAlvesGroupeBRIAND opened this issue Sep 4, 2020 · 3 comments
Assignees
Labels

Comments

@KevinAlvesGroupeBRIAND
Copy link

First, thank you for your work, xFunc is really great.


The condition of the 'if' method returns a number.

Example for algorithms IF (3 == 3; 1;-1) or IF (3 != 3; 1;-1), I have this error:

The parameter #1 has wrong type (Expected: Boolean; Actual: Number).

== -> KO
!= -> KO
>= -> OK
<= -> OK
>-> OK
< -> OK

I think the error comes from the following line:

(ResultTypes.Number, ResultTypes.Number) => ResultTypes.Number,

I resolve this with this overrided code:

    public class TypeAnalyzer_CeXFunc : TypeAnalyzer
    {
        public override ResultType Analyze(Equal exp)
        {
            var leftResult = exp.Left.Analyze(this);
            var rightResult = exp.Right.Analyze(this);

            if (leftResult is ResultType.Number && rightResult is ResultType.Number)
            {
                return ResultType.Boolean;
            }

            return base.Analyze(exp);
        }

        public override ResultType Analyze(NotEqual exp)
        {
            var leftResult = exp.Left.Analyze(this);
            var rightResult = exp.Right.Analyze(this);

            if (leftResult is ResultType.Number && rightResult is ResultType.Number)
            {
                return ResultType.Boolean;
            }

            return base.Analyze(exp);
        }
    }

However, it's possible that this issue was resolved with the issue #289


Note: Sorry for my bad english

@sys27 sys27 self-assigned this Sep 4, 2020
@sys27 sys27 added the bug label Sep 4, 2020
@sys27
Copy link
Owner

sys27 commented Sep 4, 2020

Hello, @KevinAlvesGroupeBRIAND.

You are absolutely right, this issue was fixed by #290 (latest dev branch). Since you have already found a workaround to the issue, I think you can use it, or switch to preview versions of xFunc (still can contain other issues) and I will close this ticket as resolved.

If it is really critical, I think I can fix it and publish as new 3.7.2 version later.

Thank you for reporting.

@KevinAlvesGroupeBRIAND
Copy link
Author

@sys27

I suggest releasing a new version of xFunc.
Other users are probably affected by this problem. This will allow you to have a corrected version.

@sys27
Copy link
Owner

sys27 commented Sep 4, 2020

Fixed.

@sys27 sys27 closed this as completed Sep 4, 2020
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