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

Append warnings extracted before tail call execution #6849

Merged
merged 4 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1468,12 +1468,9 @@ type Table
parse : Vector (Text | Integer | Column_Selector) | Text | Integer -> Value_Type | Auto -> Text | Data_Formatter | Nothing -> Boolean -> Problem_Behavior -> Table
parse self columns=(self.columns . filter (c-> c.value_type.is_text) . map .name) type format=Nothing error_on_missing_columns=True on_problems=Report_Warning =
selected = self.columns_helper.resolve_columns columns error_on_missing_columns=error_on_missing_columns on_problems=on_problems
result = selected.fold self table-> column_to_parse->
selected.fold self table-> column_to_parse->
new_column = column_to_parse.parse type format on_problems
table.set new_column new_name=column_to_parse.name set_mode=Set_Mode.Update
## The temporary variable for result is added due to the #6765 bug.
It should be removed once it is fixed.
result

## Splits a column of text into a set of new columns.
The original column will be removed from the table.
Expand Down Expand Up @@ -1632,12 +1629,9 @@ type Table
cast : Vector (Text | Integer | Column_Selector) | Text | Integer -> Value_Type -> Boolean -> Problem_Behavior -> Table ! Illegal_Argument | Inexact_Type_Coercion | Conversion_Failure
cast self columns=[0] value_type error_on_missing_columns=True on_problems=Problem_Behavior.Report_Warning =
selected = self.columns_helper.resolve_columns columns error_on_missing_columns=error_on_missing_columns on_problems=on_problems
result = selected.fold self table-> column_to_cast->
selected.fold self table-> column_to_cast->
new_column = column_to_cast.cast value_type on_problems
table.set new_column new_name=column_to_cast.name set_mode=Set_Mode.Update
## The temporary variable for result is added due to the #6765 bug.
It should be removed once it is fixed.
result

## ALIAS dropna
ALIAS drop_missing_rows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -929,12 +929,9 @@ type Table
cast : Vector (Text | Integer | Column_Selector) | Text | Integer -> Value_Type -> Boolean -> Problem_Behavior -> Table ! Illegal_Argument | Inexact_Type_Coercion | Conversion_Failure
cast self columns=[0] value_type error_on_missing_columns=True on_problems=Problem_Behavior.Report_Warning =
selected = self.columns_helper.resolve_columns columns error_on_missing_columns=error_on_missing_columns on_problems=on_problems
result = selected.fold self table-> column_to_cast->
selected.fold self table-> column_to_cast->
new_column = column_to_cast.cast value_type on_problems
table.set new_column new_name=column_to_cast.name set_mode=Set_Mode.Update
## The temporary variable for result is added due to the #6765 bug.
It should be removed once it is fixed.
result

## Splits a column of text into a set of new columns.
The original column will be removed from the table.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.enso.interpreter.node.callable;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
Expand Down Expand Up @@ -278,7 +277,7 @@ public Object invokeWarnings(
invokeFunctionNode.getSchema(),
invokeFunctionNode.getDefaultsExecutionMode(),
invokeFunctionNode.getArgumentsExecutionMode()));
childDispatch.setTailStatus(getTailStatus());
childDispatch.setTailStatus(TailStatus.NOT_TAIL);
childDispatch.setId(invokeFunctionNode.getId());
notifyInserted(childDispatch);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ Object doWarning(
invokeFunctionNode.getDefaultsExecutionMode(),
invokeFunctionNode.getArgumentsExecutionMode(),
thatArgumentPosition));
childDispatch.setTailStatus(getTailStatus());
childDispatch.setTailStatus(TailStatus.NOT_TAIL);
childDispatch.setId(invokeFunctionNode.getId());
notifyInserted(childDispatch);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ Object doWarning(
invokeFunctionNode.getDefaultsExecutionMode(),
invokeFunctionNode.getArgumentsExecutionMode(),
thisArgumentPosition));
childDispatch.setTailStatus(getTailStatus());
childDispatch.setTailStatus(TailStatus.NOT_TAIL);
childDispatch.setId(invokeFunctionNode.getId());
notifyInserted(childDispatch);
}
Expand Down
18 changes: 18 additions & 0 deletions test/Tests/src/Semantic/Warnings_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ throw_a_bar =

Any.is_static_nothing self x = x.is_nothing

do_fold_tail v =
v.fold 0 (+)

do_fold_non_tail v =
res = v.fold 0 (+)
res

spec = Test.group "Dataflow Warnings" <|
Test.specify "should allow to attach multiple warnings and read them back" <|
x = 1233
Expand Down Expand Up @@ -419,4 +426,15 @@ spec = Test.group "Dataflow Warnings" <|
Warning.get_all vec_2 . length . should_equal 31
Warning.limit_reached vec_2 . should_equal False

Test.specify "should preserve warnings in tail calls" <|
v = Warning.attach "Foo" [1, 2, 3]

result_tail = do_fold_tail v
result_tail . should_equal 6
Warning.get_all result_tail . map .value . should_equal ["Foo"]

result_non_tail = do_fold_non_tail v
result_non_tail . should_equal 6
Warning.get_all result_non_tail . map .value . should_equal ["Foo"]

main = Test_Suite.run_main spec