Skip to content

Commit

Permalink
propagating warnings in iif
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Aug 7, 2023
1 parent ee4167e commit f8251dc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,8 @@ type Column
error = Illegal_State.Error "`iif` got a storage "+s.to_display_text+" that does not support the `iif` operation. This is a bug in the Table library."
Panic.throw error
rs = Panic.catch No_Such_Method handler=handle_no_iif <|
s.iif true_val false_val storage_type
Java_Problems.unpack_value_with_aggregated_problems Problem_Behavior.Report_Warning <|
s.iif true_val false_val storage_type
Column.Value (Java_Column.new new_name rs)

## PRIVATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ polyglot java import org.enso.table.parsing.problems.AdditionalInvalidRows
polyglot java import org.enso.table.parsing.problems.InvalidFormat
polyglot java import org.enso.table.parsing.problems.InvalidRow
polyglot java import org.enso.table.problems.AggregatedProblems
polyglot java import org.enso.table.problems.WithAggregatedProblems
polyglot java import org.enso.table.util.problems.DuplicateNames
polyglot java import org.enso.table.util.problems.InvalidNames
## PRIVATE
Expand Down Expand Up @@ -55,3 +56,12 @@ parse_aggregated_problems problems =

if problems.getCount == problems_array.length then parsed else
parsed + [Additional_Warnings.Error (problems.getCount - problems_array.length)]

## PRIVATE
Unpacks a `WithAggregatedProblems` instance, extracting the value and
attaching any associated problems according to the provided behavior.
unpack_value_with_aggregated_problems : Problem_Behavior -> WithAggregatedProblems -> Any
unpack_value_with_aggregated_problems on_problems with_problems =
problems = parse_aggregated_problems with_problems.problems
on_problems.attach_problems_before problems <|
with_problems.value
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import org.enso.table.data.mask.SliceRange;
import org.enso.table.error.UnexpectedColumnTypeException;
import org.enso.table.error.UnexpectedTypeException;
import org.enso.table.problems.WithAggregatedProblems;
import org.enso.table.problems.WithProblems;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value;

Expand Down Expand Up @@ -201,7 +203,7 @@ public boolean isNegated() {
return negated;
}

public Storage<?> iif(Value when_true, Value when_false, StorageType resultStorageType) {
public WithAggregatedProblems<Storage<?>> iif(Value when_true, Value when_false, StorageType resultStorageType) {
Context context = Context.getCurrent();
var on_true = makeRowProvider(when_true);
var on_false = makeRowProvider(when_false);
Expand All @@ -217,7 +219,9 @@ public Storage<?> iif(Value when_true, Value when_false, StorageType resultStora

context.safepoint();
}
return builder.seal();

Storage<?> result = builder.seal();
return new WithAggregatedProblems<>(result, builder.getProblems());
}

private static IntFunction<Object> makeRowProvider(Value value) {
Expand Down

0 comments on commit f8251dc

Please sign in to comment.