-
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
Suspended default arguments cannot access previous arguments (including self
)
#8937
Comments
self
is uninitialized inside of a default-argument expression if that argument is suspendedself
When this bug gets fixed, we should revert the commit containing the workaround: |
self
self
)
I've found out that this bug is more generic: it's not only impossible to access
Actual behaviourThis script yields:
Expected behaviourObviously the
|
First investigation indicates, that this is caused by having wrong $ git diff
diff --git engine/runtime/src/main/scala/org/enso/interpreter/runtime/IrToTruffle.scala engine/runtime/src/main/scala/org/enso/interpreter/runtime/IrToTruffle.scala
index 44c72557c8..0bc588e5cf 100644
--- engine/runtime/src/main/scala/org/enso/interpreter/runtime/IrToTruffle.scala
+++ engine/runtime/src/main/scala/org/enso/interpreter/runtime/IrToTruffle.scala
@@ -2302,8 +2302,9 @@ class IrToTruffle(
): ArgumentDefinition =
inputArg match {
case arg: DefinitionArgument.Specified =>
+ val suspendedScope = scope.createChild()
val defaultExpression = arg.defaultValue
- .map(new ExpressionProcessor(scope, scopeName).run(_, false))
+ .map(new ExpressionProcessor(suspendedScope, scopeName).run(_, false))
.orNull
// Note [Handling Suspended Defaults]
@@ -2311,7 +2312,7 @@ class IrToTruffle(
assert(arg.defaultValue.isDefined)
val defaultRootNode = ClosureRootNode.build(
language,
- scope,
+ suspendedScope,
moduleScope,
defaultExpression,
makeSection(moduleScope, arg.defaultValue.get.location()), but no luck. Probably I am doing something wrong when trying to use a new |
I can fix the Here, at
the
which is obviously a bit too early as that is executed before |
Jaroslav Tulach reports a new STANDUP for yesterday (2024-05-28): Progress: - suspended defaulted args PR created and merged: #10104
|
This was a really nasty one to track down.
This repro demonstrates the problem:
Actual behaviour
As we can see, if the default argument is not suspended it all works OK -
self
is correct.However, once the argument is suspended, the
self
within it now is uninitialized.Expected behaviour
The behaviour should be the same regardless of if the argument is suspended or not.
The text was updated successfully, but these errors were encountered: