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

Integers gets resolved to double after passing in double once #887

Open
Teja-Paidimarry opened this issue Jan 31, 2025 · 1 comment
Open

Comments

@Teja-Paidimarry
Copy link

Reproducible test here

Steps to reproduce:

  1. Create a async function and pass an integer to it and assert that the return value is an integer.
  2. Pass a double and assert that the return value is a double.
  3. Pass a integer value and assert that the return value is an integer.

Right now, step (3) fails and returns an double.

Note: This only happens when we use an async function. Synchronous function do seem to work fine 👍

@woess
Copy link
Member

woess commented Feb 12, 2025

We don't guarantee that integers will stay integers. Please don't rely on a particular numeric type. I suggest to expect a Number instead and use Number.intValue()/doubleValue() to convert. If you use the polyglot Value API, there's Value.fitsInInt() and Value.asInt()/asDouble() for that purpose. You can also use IntConsumer or DoubleConsumer to force automatic conversion.

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