-
Notifications
You must be signed in to change notification settings - Fork 321
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
Support on_problems=Problem_Behavior.Report_Warning and Map_Error wrapping in Vector.map #8595
Conversation
This reverts commit c30d171.
CHANGELOG.md
Outdated
@@ -599,6 +599,7 @@ | |||
- [Support for loading big Excel files.][8403] | |||
- [Added new `Filter_Condition`s - `Equal_Ignore_Case`, `Is_Nan`, `Is_Infinite` | |||
and `Is_Finite`.][8539] | |||
- Support `on_problems=Problem_Behavior.Report_Warning` in `Vector.map`.][8595] |
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.
- Support `on_problems=Problem_Behavior.Report_Warning` in `Vector.map`.][8595] | |
- [Support `on_problems=Problem_Behavior.Report_Warning` in `Vector.map`.][8595] |
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.
Done
Describes an error attached to a value within a `Vector`. The `index` field | ||
contains the index into the `Vector` at which the error occurred. | ||
|
||
If a value is a nested within multiple `Vector`s, its warnings are wrapped |
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.
If a value is a nested within multiple `Vector`s, its warnings are wrapped | |
If a value is nested within multiple `Vector`s, its warnings are wrapped |
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.
Done
distribution/lib/Standard/Base/0.0.0-dev/src/Internal/Array_Like_Helpers.enso
Outdated
Show resolved
Hide resolved
…ke_Helpers.enso Co-authored-by: Radosław Waśko <radoslaw.wasko@enso.org>
@@ -307,8 +307,6 @@ public Object invokeWarnings( | |||
|
|||
if (result instanceof DataflowError) { | |||
return result; | |||
} else if (result instanceof WithWarnings withWarnings) { |
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 case is already handled by WithWarnings.wrap
.
test/Tests/src/Data/Json_Spec.enso
Outdated
@@ -164,6 +164,13 @@ spec = | |||
obj1 . should_not_equal <| JS_Object.from_pairs [["a", 43], ["b", 123]] | |||
obj1 . should_not_equal <| JS_Object.from_pairs [["a", 42], ["b", JS_Object.from_pairs [["c",1], ["d",3]]]] | |||
|
|||
Test.specify "should be able to set values" <| |
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 part of #8630, which will be merged first.
@@ -617,7 +617,8 @@ private boolean generateWarningsCheck( | |||
+ " = withWarnings.getValue();"); | |||
out.println( | |||
" gatheredWarnings =" | |||
+ " gatheredWarnings.prepend(withWarnings.getReassignedWarningsAsRope(bodyNode));"); |
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.
Done
Describes an error attached to a value within a `Vector`. The `index` field | ||
contains the index into the `Vector` at which the error occurred. | ||
|
||
If a value is a nested within multiple `Vector`s, its warnings are wrapped |
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.
Done
CHANGELOG.md
Outdated
@@ -599,6 +599,7 @@ | |||
- [Support for loading big Excel files.][8403] | |||
- [Added new `Filter_Condition`s - `Equal_Ignore_Case`, `Is_Nan`, `Is_Infinite` | |||
and `Is_Finite`.][8539] | |||
- Support `on_problems=Problem_Behavior.Report_Warning` in `Vector.map`.][8595] |
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.
Done
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 see that a lot of thought and work has been put into this PR. Let's get it in! I'd update the description of the PR (as that usually gets copied to Git commit description). I'd somehow point readers to docs/semantics/wrapped-errors.md
as that contains great explanation of the overall design.
not a wrapping error, it is returned unchanged. | ||
unwrap : Any -> Any | ||
unwrap error_value = | ||
Panic.catch No_Such_Conversion handler=_->error_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.
Interesting use of conversion. Convert to Wrapped_Error
and then use inner_error
. I can see that the Error.unwrap
method is applied recursively to strip off all the wrappers. Consider adding @Tail_Call
annotation to turn it into a loop.
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.
Done.
test/Benchmarks/src/Warnings.enso
Outdated
|
||
builder.group "warnings_get_all_wrapped_"+vector_type options group_builder-> | ||
group_builder.specify "no_warnings" <| | ||
Warning.get_all_wrapped data.no_warnings |
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.
Where is the get_all_wrapped
function defined? Aren't we supposed to use get_all wrap_errors=True?
Implements Warnings.get_all_wrapped which wraps warnings
If we shall be using get_all wrap_errors=True
then I'd like to point out the pull request description is outdated.
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.
Fixed.
|
||
## Catching Wrapped Errors | ||
|
||
Wrapped errors are "transparent" to `Error.catch`. That is, if you attempt to |
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.
+1
docs/semantics/wrapped-errors.md
Outdated
|
||
## Implementing Error Wrappers | ||
|
||
An error wrapper is a regular Enso value that has a conversion to `Wrapped_Error`. For example: |
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.
+1
Done. This PR is blocked by the error "Invariant contract violation for receiver Nothing" when runtime assertions are turned on. I am unable to reproduce it with a single test, or under the debugger. Discussion here: https://discord.com/channels/401396655599124480/1194662721958969364/1194662721958969364
|
Looks like that eventually violates Truffle invariants and was lurking around.
"interop.isMetaObject(metaLeft)", | ||
"!interop.isNull(metaRight)", | ||
"interop.isMetaObject(metaRight)" | ||
}) |
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.
Do we know how to reproduce the problem?
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.
run stdlib test/Tests
with assertions on. I haven't been able to reduce it to something small yet.
@GregoryTravis
@JaroslavTulach are you OK with merging it with my workaround? @Akirathan will create a PR with a smaller case but I don't think it makes sense to block this work because it is unrelated to Greg's change. |
Pull Request Description
Implements
Warnings.get_all wrap_errors=True
which wraps warnings attached to values inside vectors withMap_Error
, which includes the position of the value within the vector. See the documentation for more details.get_all wrap_errors=True
does not change the warnings that are attached to values -- it wraps them before returning them to the caller, but does not change the original warnings attached to the values.Wrapped warnings only appear attached to the vector itself. The values inside the vector do not have their warnings wrapped.
Warning propagation is not changed at all;
Warnings.get_all
(with defaultwrap_errors=False
) behaves as before.get_all wrap_errors=True
is meant to be used primarily by the IDE, although it can be used anywhere this wrapping is desired.Important Notes
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.