-
Notifications
You must be signed in to change notification settings - Fork 323
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
Enso Date shall be converted to java.time.LocalDate when passed to Java #3374
Conversation
engine/runtime/src/main/java/org/enso/interpreter/runtime/callable/atom/Atom.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/callable/atom/Atom.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/DateTest.scala
Outdated
Show resolved
Hide resolved
engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/DateTest.scala
Outdated
Show resolved
Hide resolved
Think this would convert any Atom where first field is a The original problem, I was meaning was coercing I don't believe this fix would do anything when coming back with a LocalDate to Enso. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to put more thought into API design here.
engine/runtime/src/main/java/org/enso/interpreter/runtime/callable/atom/Atom.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/DateTest.scala
Outdated
Show resolved
Hide resolved
I agree with @kustosz suggestion. I think we probably need to make Date/DateTime/Time part of the built in space, but it would be also helpful to control how an Enso Atom is converted across the boundary. This clearly needs some API design. |
Right, it didn't do anything. Thanks for pointing that out, James. Since d4a8e31 it is tested.
As soon as the engine encounters a foreign object that represents a date, it needs to wrap it/convert it/mimic it by Enso
...there is an API between the Engine and the I guess I try to hack something first and then we can think of proper API to do it nicer. |
...in/java/org/enso/interpreter/node/expression/builtin/interop/syntax/HostValueToEnsoNode.java
Outdated
Show resolved
Hide resolved
ca616b8
to
87cf546
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we are ready for another round of review. Thanks in advance for your comments.
engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeMethodNode.java
Outdated
Show resolved
Hide resolved
...ne/runtime/src/main/java/org/enso/interpreter/node/callable/resolver/HostMethodCallNode.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice. Some nitpicks / discussion points inline. Also please make sure it doesn't make things slower.
engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeMethodNode.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeMethodNode.java
Outdated
Show resolved
Hide resolved
...ne/runtime/src/main/java/org/enso/interpreter/node/callable/resolver/HostMethodCallNode.java
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/callable/atom/Atom.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/node/callable/InvokeMethodNode.java
Outdated
Show resolved
Hide resolved
028335a
to
eee9bf2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
engine/runtime/src/main/java/org/enso/interpreter/runtime/Context.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/callable/atom/Atom.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, there's just one stylistic choice I disagree with and it seems like code formatting is off in general. Approving, as fixing these shouldn't require another review from me :)
engine/runtime/src/main/java/org/enso/interpreter/runtime/Context.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/runtime/callable/atom/Atom.java
Outdated
Show resolved
Hide resolved
eee9bf2
to
1252ec0
Compare
Significantly improves the polyglot Date support (as introduced by #3374). It enhances the `Date_Spec` to run it in four flavors: - with Enso Date (as of now) - with JavaScript Date - with JavaScript Date wrapped in (JavaScript) array - with Java LocalDate allocated directly The code is then improved by necessary modifications to make the `Date_Spec` pass. # Important Notes James has requested in [#181755990](https://www.pivotaltracker.com/n/projects/2539304/stories/181755990) - e.g. _Review and improve InMemory Table support for Dates, Times, DateTimes, BigIntegers_ the following program to work: ``` foreign js dateArr = """ return [1, new Date(), 7] main = IO.println <| (dateArr.at 1).week_of_year ``` the program works with here in provided changes and prints `27` as of today. @jdunkerley has provided tests for proper behavior of date in `Table` and `Column`. Those tests are working as of [f16d07e](f16d07e). One just needs to accept `List<Value>` and then query `Value` for `isDate()` when needed. Last round of changes is related to **exception handling**. 8b686b1 makes sure `makePolyglotError` accepts only polyglot values. Then it wraps plain Java exceptions into `WrapPlainException` with `has_type` method - 60da5e7 - the remaining changes in the PR are only trying to get all tests working in the new setup. The support for `Time` isn't part of this PR yet.
Pull Request Description
This PR provides a unit test, an integration test and code changes to guarantee automatic conversion of
java.time.LocalDate
to EnsoDate
atom and back.Originally (after the first few commits) the following test failed:
then this PR seeks to provide a fix. The PR has been enhanced with another test that sends
java.time.LocalDate
back to Enso and fails with:Now all the unit as well as integration tests pass OK.
Important Notes
Checklist
Please include the following checklist in your PR: