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

Delay check of suspended arguments until they are about to be computed #7727

Merged

Conversation

JaroslavTulach
Copy link
Member

@JaroslavTulach JaroslavTulach commented Sep 5, 2023

Pull Request Description

Fixes #6883 by wrapping suspended arguments by Function that adds a type check on the computed value.

Checklist

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

  • All code follows the
    Java,
  • All code has been tested:
    • 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 Sep 5, 2023
@JaroslavTulach JaroslavTulach self-assigned this Sep 5, 2023
try {
org.enso.interpreter.runtime.EnsoContext ctx = EnsoContext.get(this);
java.lang.Object newValue = invoke.execute(fn, null, State.create(ctx), new Object[0]);
set.execute(atom, newValue);
return newValue;
} catch (AbstractTruffleException ex) {
var rethrow = new SuspendedException(ex);
var rethrow = DataflowError.withTrace(ex, ex);
set.execute(atom, rethrow);
Copy link
Member Author

Choose a reason for hiding this comment

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

set.execute was failing with SuspendedException because the lazy field are runtime type checked and SuspendedException didn't have the right type ;-)

Changing into DataflowError as that is isAllFitValue.

assertNotNull("member found", thirteen);
assertEquals(13, thirteen.asInt());

var someHello = complex.execute("Hello", "World");
Copy link
Member Author

@JaroslavTulach JaroslavTulach Sep 5, 2023

Choose a reason for hiding this comment

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

Constructing Int.Complex is allowed, as the unwrap value is left as thunk. Only reading it later yields the error.

@JaroslavTulach JaroslavTulach merged commit ab1c1a4 into develop Sep 6, 2023
@JaroslavTulach JaroslavTulach deleted the wip/jtulach/SuspendedArgumentsTypeCheck_6883 branch September 6, 2023 07:34
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.

Check types of lazy (constructor) arguments
2 participants