You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To reproduce, create a file polyglot/java/foo/foo/Foo.java and compile it:
packagefoo;
importjava.math.BigInteger;
importjava.math.BigDecimal;
publicclassFoo {
publicstaticBigDecimalgenerate(BigIntegeri) {
BigDecimald = newBigDecimal(i);
System.out.println("In Java " + i + " is mapped thru new BigDecimal() to " + d);
returnd;
}
}
and then run the following src/Main.enso:
from Standard.Base import all
polyglot java import foo.Foo
polyglot java import java.math.BigDecimal
main =
x = 2^70
IO.println (x.to_text + " is " + (Meta.type_of x).to_text)
d = BigDecimal.new x
IO.println ("In Enso " + x.to_text + " is mapped thru BigDecimal.new to " + d.to_text + " (" + (Meta.type_of d).to_text + ")")
d2 = Foo.generate x
IO.println ("which back in Enso is " + d2.to_text + " (" + (Meta.type_of d2).to_text + ")")
IO.println ("What about smaller numbers? " + (BigDecimal.new 123).to_text)
it yields
1180591620717411303424 is Integer
In Enso 1180591620717411303424 is mapped thru BigDecimal.new to 0 (java.math.BigDecimal)
In Java 1180591620717411303424 is mapped thru new BigDecimal() to 1180591620717411303424
which back in Enso is 1180591620717411303424 (java.math.BigDecimal)
What about smaller numbers? 123
As we can see, surprisingly - when I call BigDecimal.new in Enso, it creates a new BigDecimal of value 0. However, if I call new BigDecimal(_) in Java and then pass the value back to Enso, the value is correctly preserved. Interestingly, if the BigDecimal.new argument is a small number, it correctly creates a new BigDecimal instance of the correct value.
This seems like a bug in the handling of interoperability of Big Integers. I'm not exactly sure if this is a bug directly in Enso or in Truffle interop - this remains to be discovered. If we discover it's a Truffle issue we can create another bug report there, but I wanted a place to track this problem.
The text was updated successfully, but these errors were encountered:
Pull Request Description
I couldn't stand the amount of extra output that we got when compiling a clean project and when executing regular tests. We should strive to keep output clean and not p...
To reproduce, create a file
polyglot/java/foo/foo/Foo.java
and compile it:and then run the following
src/Main.enso
:it yields
As we can see, surprisingly - when I call
BigDecimal.new
in Enso, it creates a newBigDecimal
of value0
. However, if I callnew BigDecimal(_)
in Java and then pass the value back to Enso, the value is correctly preserved. Interestingly, if theBigDecimal.new
argument is a small number, it correctly creates a new BigDecimal instance of the correct value.This seems like a bug in the handling of interoperability of Big Integers. I'm not exactly sure if this is a bug directly in Enso or in Truffle interop - this remains to be discovered. If we discover it's a Truffle issue we can create another bug report there, but I wanted a place to track this problem.
The text was updated successfully, but these errors were encountered: