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

Polish to_text on intersection types #12192

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

JaroslavTulach
Copy link
Member

Pull Request Description

Fixes #11827 by better coordination of dispatch to EnsoMultiValue.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • All code follows the
    Scala,
    Java,
  • Unit tests have been written where possible.

@JaroslavTulach JaroslavTulach added the CI: No changelog needed Do not require a changelog entry for this PR. label Jan 30, 2025
@JaroslavTulach JaroslavTulach self-assigned this Jan 30, 2025
@JaroslavTulach JaroslavTulach marked this pull request as draft January 30, 2025 11:50
@JaroslavTulach JaroslavTulach changed the title Polish to_text on _intersection types_ Polish to_text on intersection types Jan 30, 2025
@JaroslavTulach JaroslavTulach force-pushed the wip/jtulach/MultiValueToText11827 branch from 91597b5 to 3196767 Compare January 30, 2025 14:41
@@ -302,7 +302,7 @@ Object doMultiValue(
if (fnAndType != null) {
var ctx = EnsoContext.get(this);
if (ctx.getBuiltins().any() != fnAndType.getRight()) {
var unwrapSelf = castTo.findTypeOrNull(fnAndType.getRight(), self, false, false);
var unwrapSelf = castTo.findTypeOrNull(fnAndType.getRight(), self, true, false);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reorders the intersection types to make sure the value of the type we dispatch the method to is at EnsoMultiValue.firstDispatch.

ab.a_id_unchecked . is_a A . should_be_true
ab.a_id_unchecked . is_a B . should_be_true
ab.a_id_unchecked.a_method . should_equal "A method"
ab.a_id_unchecked.b_method . should_equal "B method"
Test.expect_panic No_Such_Method (ab.a_id_unchecked.b_method)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a result of 3196767 we have to make sure that dispatching a method on self moves the type of the method to the firstDispatch. This is done by https://github.com/enso-org/enso/pull/12192/files#r1935731256, but:

  • right now the reordering hides all the other types
  • semantically it is not necessary to hide the other types
  • we could keep them visible

It is just simpler to hide the other types as there is an implementation doing that available right now. Opinions? Wanna better behavior at no slowdown? CCing @radeusgd.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure yet as all of this has many implications that only come out in practice.

But at first, I think that hiding actually seems consistent with type checking requirements - inside of method A.foo self I actually do want to assume that self:A - so it makes sense for other 'parts' to be hidden.

@JaroslavTulach
Copy link
Member Author

Now, when dispatch of an instance method allows self to be an EnsoMultiValue we have problems with builtins! They don't want multi value, but they need the right type to be extracted from the multivalue:

To do so we have to change the "builtin prelude code" - e.g. the way we prepare the values before invoking the @BuiltinMethod. The work is blocking progress on this PR, but it should rather be implemented as a separate PR #12201 to make sure compatibility is fully guaranteed.

@enso-bot
Copy link

enso-bot bot commented Feb 5, 2025

Jaroslav Tulach reports a new STANDUP for yesterday (2025-02-04):

Progress: .

GitHub
Enso Analytics is a self-service data prep and analysis platform designed for data teams. - Benchmark Engine · 3579139
GitHub
We wanted to provide additional context for the work of moving our build system to Bazel, answer common questions, provide some expectations, and explain our long-term goals. So here it is. Goals W...

@enso-bot
Copy link

enso-bot bot commented Feb 6, 2025

Jaroslav Tulach reports a new STANDUP for yesterday (2025-02-05):

Progress: .

GitHub
Pull Request Description Fixes #7117 by removing State from method signatures and moving it into EnsoContext thread context local variable. Checklist Please ensure that the following checklist has ...

@enso-bot
Copy link

enso-bot bot commented Feb 7, 2025

Jaroslav Tulach reports a new STANDUP for yesterday (2025-02-06):

Progress: .

Discord
Discord is great for playing games and chilling with friends, or even building a worldwide community. Customize your own space to talk, play, and hang out.

@enso-bot
Copy link

enso-bot bot commented Feb 7, 2025

Jaroslav Tulach reports a new STANDUP for today (2025-02-07):

Progress: .

Discord
Discord is great for playing games and chilling with friends, or even building a worldwide community. Customize your own space to talk, play, and hang out.

mergify bot pushed a commit that referenced this pull request Feb 8, 2025
#12201)

- as #12192 (comment) states:
- there is a need to extract values from `EnsoMultiValue` in the _"builtin method prelude code"_
- to enable _specializations based on type of arguments_, we need to wrap such _prelude_ by a `Node`
- hence introducing `ArgNode` & co.
- it kinda replaces the _"static code emitted"_ by annotation processor
- with Truffle `@Specialization`s done inside of `ArgNode`
- making this all more Truffle-like
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Let EnsoMultiValue.to_text delegate to first type to_text
3 participants