-
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
Multi value Complex
test and robustness refactoring
#11525
Conversation
New 4387ccf tests are running and are green: |
Interesting failure in all engine tests:
|
The failure is caused by creating cycle in the Truffle AST! I guess it is time to rewrite |
With 04d3835 we can finally try to address #11482 and specify the return type of the diff --git test/Base_Tests/src/Data/Complex.enso test/Base_Tests/src/Data/Complex.enso
index 9a0c98590b..41dd0c5567 100644
--- test/Base_Tests/src/Data/Complex.enso
+++ test/Base_Tests/src/Data/Complex.enso
@@ -10,7 +10,7 @@ import project.Data.Complex_Helpers.Complex_Comparator
type Complex
private Value re:Float im:Float
- new re=0:Float im=0:Float =
+ new re=0:Float im=0:Float -> Complex =
c = Complex.Value re im
if im != 0 then c:Complex else
c.as_complex_and_float with this change the |
Complex
test and robustness refactoring
|
||
## explicit "conversion" of `Complex` to `Float` in a private module | ||
used in `as_complex_and_float` | ||
Float.from (that:Complex) = |
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.
Info for library guys (@jdunkerley, @radeusgd, @GregoryTravis, etc.). You can implement values with mutiple roles even right now. Steps:
- define a
type Complex
in one file - create another
private
helper module with explicit conversion - define extension method on
Complex
that creates the mixed in value - e.g.as_complex_and_float
- when you want to "mix" multiple types into
Complex
- call such extension method
Your review is welcomed.
engine/runtime/src/main/java/org/enso/interpreter/node/typecheck/TypeCheckValueNode.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.
I am not entirelly sure what is going on in the code. But it is definitely better than adding all type checking under ReadArgumentNode
.Before integrating, please ensure that all benchmarks seems OK.
engine/runtime/src/main/java/org/enso/interpreter/node/callable/argument/ReadArgumentNode.java
Outdated
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/node/typecheck/TypeCheckValueNode.java
Show resolved
Hide resolved
engine/runtime/src/main/java/org/enso/interpreter/node/typecheck/LazyCheckRootNode.java
Outdated
Show resolved
Hide resolved
import org.enso.interpreter.runtime.callable.function.Function; | ||
import org.enso.interpreter.runtime.callable.function.FunctionSchema; | ||
|
||
final class LazyCheckRootNode extends RootNode { |
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.
Why this class does not extend EnsoRootNode
? By extending it, we would have functionality like source section and associated scopes.
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.
Probably because it represents internal function only:
Function wrapThunk(Function thunk) {
return new Function(getCallTarget(), thunk.getScope(), SCHEMA, new Object[] {thunk}, null);
}
In any case, I am not aware of any missing source sections or scopes.
engine/runtime/src/main/java/org/enso/interpreter/node/typecheck/AbstractTypeCheckNode.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.
Good to correct the typo @Akirathan spotted.
engine/runtime/src/main/java/org/enso/interpreter/node/typecheck/AbstractTypeCheckNode.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
While working on #11482 and enhancing the tests suite with more tests based on `type Complex` a [getRootNode() did not terminate in 100000 iterations](#11525 (comment)) problem was discovered. Detailed investigation revealed that the existing `ReadArgumentCheckNode` infrastructure was able to create a **cycle** of parent pointers in the Truffle AST. The problem was in intricate manipulation of the AST while rewriting internals in `ReadArgumentCheckNode`. This PR avoids such manipulation by _refactoring the type checking code_. `ReadArgumentNode` knows nothing about types anymore. When a type check is needed, `IrToTruffle` adds additional `TypeCheckValueNode.wrap` around the `ReadArgumentNode` - that breaks the **vicious circle**. All the _type checks_ nodes are moved to its own package. All but one of the classes are made package private. The external API for doing _type checking_ is concentrated into `TypeCheckValueNode`.
Pull Request Description
While working on #11482 and enhancing the tests suite with more tests based on
type Complex
a getRootNode() did not terminate in 100000 iterations problem was discovered. Detailed investigation revealed that the existingReadArgumentCheckNode
infrastructure was able to create a cycle of parent pointers in the Truffle AST.The problem was in intricate manipulation of the AST while rewriting internals in
ReadArgumentCheckNode
. This PR avoids such manipulation by refactoring the type checking code.ReadArgumentNode
knows nothing about types anymore. When a type check is needed,IrToTruffle
adds additionalTypeCheckValueNode.wrap
around theReadArgumentNode
- that breaks the vicious circle.All the type checks nodes are moved to its own package. All but one of the classes are made package private. The external API for doing type checking is concentrated into
TypeCheckValueNode
.Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,