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

MathProcessor narrowing types #20

Open
dohrayme opened this issue Aug 5, 2011 · 1 comment
Open

MathProcessor narrowing types #20

dohrayme opened this issue Aug 5, 2011 · 1 comment

Comments

@dohrayme
Copy link

dohrayme commented Aug 5, 2011

MVEL 2.0.19

If I have a function:

def abs(x) {
(x >= 0) ? x : -x
}

and use it thus: abs(Integer / BigDecimal)

where the egress type is going to be (is fixed to be) a BigDecimal, a ClassCast exception is thrown during the abs function negation step. Investigating I see a BigDecimal signer is being used but the division operation result has had its type narrowed to be a Double, see MathsProcessor::_doOperations it always passes true to doBigDecimalArithmetic which results in the type being narrowed. Should this not be conditional on the operands and return type?

@mikebrock
Copy link
Owner

Can you confirm this is still a problem in MVEL 2.1.Beta6, because there will be no 2.0.20. 2.1 is the next 2.x.x version.

On Aug 5, 2011, at 6:35 AM, dohrayme wrote:

MVEL 2.0.19

If I have a function:

def abs(x) {
(x >= 0) ? x : -x
}

and use it thus: abs(Integer / BigDecimal)

where the egress type is going to be (is fixed to be) a BigDecimal, a ClassCast exception is thrown during the abs function negation step. Investigating I see a BigDecimal signer is being used but the division operation result has had its type narrowed to be a Double, see MathsProcessor::_doOperations it always passes true to doBigDecimalArithmetic which results in the type being narrowed. Should this not be conditional on the operands and return type?

Reply to this email directly or view it on GitHub:
#20

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

No branches or pull requests

2 participants