-
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
Deliver full intersection type of a value to the IDE #11583
Conversation
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.
The change itself is fine, but it reveals long term unresolved issues:
- are incompatible changes in the protocol OK?
- versioning on the protocol is missing
- duplication of functionality instead of encapsulating it in
TypeOfNode
@@ -195,7 +195,7 @@ export interface ExpressionUpdate { | |||
/** The id of updated expression. */ | |||
expressionId: ExpressionId | |||
/** The updated type of the expression. */ | |||
type?: string | |||
type: string[] |
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.
This is an incompatible message change. Single values used to be represented as "string"
and now they will be [ "string" ]
. Are we sure we don't need compatibility?
@@ -367,7 +367,7 @@ interface ExpressionUpdate { | |||
/** The id of updated expression. */ | |||
expressionId: ExpressionId; | |||
/** The updated type of the expression. */ | |||
type?: string; | |||
type: string[]; |
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 feel incompatible changes should be versioned and documented. We should:
- increase the version of the protocol
- describe what change has happened and why it is incompatible
Sure, I know we have no version of the protocol. However I asked for it a year ago. Moreover recently there were complains about incompatibilities between cloud/IDE and the conclusion was: we should at least detect the incompatibilities by versioning our protocols.
engine/polyglot-api/src/main/scala/org/enso/polyglot/runtime/Runtime.scala
Show resolved
Hide resolved
...runtime-instrument-common/src/main/java/org/enso/interpreter/service/ExecutionCallbacks.java
Outdated
Show resolved
Hide resolved
@@ -198,14 +198,14 @@ object ProgramExecutionSupport { | |||
val notExecuted = | |||
methodCallsCache.getNotExecuted(executionFrame.cache.getCalls) | |||
notExecuted.forEach { expressionId => | |||
val expressionType = executionFrame.cache.getType(expressionId) | |||
val expressionCall = executionFrame.cache.getCall(expressionId) | |||
val expressionTypes = executionFrame.cache.getType(expressionId) |
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.
Shouldn't the getType
method be renamed to getTypes
?
...tests/src/test/scala/org/enso/interpreter/test/instrument/RuntimeIntersectionTypesTest.scala
Outdated
Show resolved
Hide resolved
@@ -367,7 +367,7 @@ interface ExpressionUpdate { | |||
/** The id of updated expression. */ | |||
expressionId: ExpressionId; | |||
/** The updated type of the expression. */ |
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.
The current docs are not clear about some details of the protocol. An empty array seems to be treated specially; judging from the implementation, it looks like:
- When the status is
Pending
, an empty array can indicate that the type has not been determined yet. - When the status is not
Pending
, an empty array indicates that no specific type is known for the value--maybe this can happen either if the type is known to beAny
. Can this also happen if the type could not be determined?
Are these updates incremental? It's not clear whether in the pending state []
might be sent to indicate "no change", or every update will contain all currently-known type information even if it hasn't changed.
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 updated the docs. The logic did not change. The array is just a way to encode intersection types
[]
indicates no type information (previouslynull
)[T]
represent a type of the expression (previouslyT
)[T,U]
represents an intersection typeT & U
(previously not supported, probably delivered just as aT
type)
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.
In this particular case I would agree with Jaroslav that the binary incompatible change this PR introduces might be problematic.
We could have both, type
and types
, fields be present for the time being at the cost of some duplication. Then GUI could make a switch to support intersection types more gently and we could deprecate (and eventually remove)type
.
case msg: Api.ExpressionUpdates if state.isSuggestionUpdatesRunning => | ||
state.suggestionUpdatesQueue.enqueue(msg) | ||
|
||
case Api.ExpressionUpdates(_, updates) => |
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 change? Seems rather unrelated. Or is that feature no longer used?
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.
Yes, after the component browser is finished, and GUI can handle suggestions itself, we don't need to do this logic anymore
engine/polyglot-api/src/main/scala/org/enso/polyglot/runtime/Runtime.scala
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.
The change in TypeOfNode
isn't correct and fails on Truffle asserts. I'll prepare an alternative approach.
@@ -75,6 +75,11 @@ Object doWarning(WithWarnings value, @Cached TypeOfNode withoutWarning) { | |||
return withoutWarning.execute(value.getValue()); | |||
} | |||
|
|||
@Specialization | |||
Object doEnsoMultiValue(EnsoMultiValue value) { | |||
return value.allTypes(); |
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.
Hello Dmitry,
thanks for trying to implement my request to concentrate the logic of obtaining a type array into TypeOfNode
in 86bfb98, but this cannot work - the Object
here means: any valid interop value and Java arrays aren't such values.
Such a code change isn't likely to pass the Truffle assert
checks as for example this failure indicates
The change has to be done differently. I'll prepare a PR for review:
With 87e738b there is findAllTypes
method that provides all the Type[]
associated with a value.
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 can wrap the result in EnsoObject
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 can wrap the result in EnsoObject
Interesting idea, yes that would fix the Truffle assertion errors:
- use
ArrayLikeHelpers.wrapEnsoObjects
- let's see what other failures we get
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, I should wait for #11618
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.
- yes, use Giving TypeOfNode richer query API #11618 API now when it has been integrated
engine/polyglot-api/src/main/scala/org/enso/polyglot/runtime/Runtime.scala
Show resolved
Hide resolved
mockSuggestions.json probably needs to be regenerated here (@farmaazon?) |
@somebody1234 it does not change the suggestion interface. This change is only about the expression update. |
🧪 Storybook is successfully deployed!📊 Dashboard:
|
} | ||
|
||
var typeOfNode = TypeOfNode.getUncached(); | ||
Type[] allTypes = value == null ? null : typeOfNode.findAllTypesOrNull(value); |
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.
Nice.
- Update mock data for multi-type expression updates (#11583)
- Update mock data for multi-type expression updates (#11583)
- Update mock data for multi-type expression updates (#11583)
Fix failing integration tests: - Fix a Vue Teleporter crash that became reachable when the dropdown arrow is displayed more often (#11620). - Fix a new drag-and-drop test that didn't work in CI. - Update mock data for multi-type expression updates (#11583). # Important Notes - The new `ConditionalTeleport` component should be used for any `Teleport` that uses the `disabled` prop and has a `to` that isn't always a valid teleportation target.
Fix failing integration tests: - Fix a Vue Teleporter crash that became reachable when the dropdown arrow is displayed more often (#11620). - Fix a new drag-and-drop test that didn't work in CI. - Update mock data for multi-type expression updates (#11583). # Important Notes - The new `ConditionalTeleport` component should be used for any `Teleport` that uses the `disabled` prop and has a `to` that isn't always a valid teleportation target.
Pull Request Description
close #11481
Changelog:
MultiTypeValue
results in the execution instrumentImportant Notes
GUI uses only the first type of the intersection. See the difference between
Integer&Text
andText&Integer
:enso-11481-intersection-types.mp4
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.