Skip to content

Commit 1df9ea6

Browse files
raiseAssertionPanic instead of shouldNotReachHere (#11877)
1 parent 34ddd37 commit 1df9ea6

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

distribution/lib/Standard/Base/0.0.0-dev/src/Warning.enso

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ type Warning
9090
Arguments:
9191
- value: the value to which warnings should be set to.
9292
- warnings: vector of warnings to set to the value.
93-
set : Any -> Vector Warning -> Any
94-
set value warnings = set_array value warnings
93+
set value (warnings:Vector Warning) = set_array value warnings
9594

9695
## PRIVATE
9796
ADVANCED

engine/runtime/src/main/java/org/enso/interpreter/runtime/warning/SetWarningsNode.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.enso.interpreter.runtime.warning;
22

3-
import com.oracle.truffle.api.CompilerDirectives;
43
import com.oracle.truffle.api.dsl.Cached;
54
import com.oracle.truffle.api.dsl.Cached.Shared;
65
import com.oracle.truffle.api.dsl.GenerateUncached;
@@ -91,9 +90,7 @@ Object doSetInteropArray(
9190
} else {
9291
return new WithWarnings(object, maxWarns, isLimitReached, warnMap);
9392
}
94-
} catch (UnsupportedMessageException | InvalidArrayIndexException e) {
95-
throw CompilerDirectives.shouldNotReachHere(e);
96-
} catch (ClassCastException e) {
93+
} catch (ClassCastException | UnsupportedMessageException | InvalidArrayIndexException e) {
9794
throw ctx.raiseAssertionPanic(this, "Expected Warning, got something else", e);
9895
}
9996
}
@@ -106,7 +103,7 @@ protected static boolean isEmpty(Object warns, InteropLibrary interop) {
106103
try {
107104
return interop.getArraySize(warns) == 0;
108105
} catch (UnsupportedMessageException e) {
109-
throw CompilerDirectives.shouldNotReachHere(e);
106+
return false;
110107
}
111108
}
112109
return false;

test/Base_Tests/src/Semantic/Warnings_Spec.enso

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,11 @@ add_specs suite_builder = suite_builder.group "Dataflow Warnings" group_builder-
451451
res2 . should_equal True
452452
Warning.get_all res2 . map .value . should_equal ["WARNING2"]
453453

454+
group_builder.specify "warning & panic" <|
455+
panic_text = Panic.catch Standard.Base.Errors.Common.Type_Error (Warning.set 1 2) caught_panic->
456+
caught_panic.payload.to_text
457+
panic_text . should_equal "Type error: expected `warnings` to be Vector, but got Integer."
458+
454459
main filter=Nothing =
455460
suite = Test.build suite_builder->
456461
add_specs suite_builder

0 commit comments

Comments
 (0)