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

Basic operations (+, -, *, /) between uint64 and int32 not working #247

Open
mocakturk opened this issue Aug 18, 2022 · 3 comments
Open

Comments

@mocakturk
Copy link

Hello,

When I execute following expression, I have exception with message: "Invalid Operation".
"10ul + 20"
(default numeric type is int32)

Normally, uint64 and int32 types should work together. The result should be 30ul in normal conditions.

@holdenmai
Copy link
Contributor

This is an interesting scenario where the compiler gives results that seem conflicting to me.

var result = 10ul + 5;
works exactly as stated in original comment.

However,

var l = 10ul;
var r = 5;
var result = l + r;

results in a compiler error saying the 'Operator "+" is ambiguous on operators of type 'ulong' and 'int''

Anybody have any insight on that?

@davideicardi
Copy link
Member

This is actually quite strange. I suppose that in the first case the compiler is able to infer the type based on the previous number, probably this is some kind of compiler optimization where at the end only 15ul is generated.

What is your use case? Why you need to work with ul numbers? Just to understand if there can be alternatives ...

@davideicardi davideicardi added question and removed bug labels Aug 24, 2022
@mocakturk
Copy link
Author

There are some custom functions I've included:
CustomFuncReturnsUint64() + CustomFuncReturnsInt32()

User is able to freely type a formula in my application. This is a possible case.

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

No branches or pull requests

3 participants