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

raiseAssertionPanic instead of shouldNotReachHere #11877

Merged
merged 1 commit into from
Dec 17, 2024
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
3 changes: 1 addition & 2 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Warning.enso
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ type Warning
Arguments:
- value: the value to which warnings should be set to.
- warnings: vector of warnings to set to the value.
set : Any -> Vector Warning -> Any
set value warnings = set_array value warnings
set value (warnings:Vector Warning) = set_array value warnings

## PRIVATE
ADVANCED
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.enso.interpreter.runtime.warning;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Cached.Shared;
import com.oracle.truffle.api.dsl.GenerateUncached;
Expand Down Expand Up @@ -91,9 +90,7 @@ Object doSetInteropArray(
} else {
return new WithWarnings(object, maxWarns, isLimitReached, warnMap);
}
} catch (UnsupportedMessageException | InvalidArrayIndexException e) {
throw CompilerDirectives.shouldNotReachHere(e);
} catch (ClassCastException e) {
} catch (ClassCastException | UnsupportedMessageException | InvalidArrayIndexException e) {
throw ctx.raiseAssertionPanic(this, "Expected Warning, got something else", e);
}
}
Expand All @@ -106,7 +103,7 @@ protected static boolean isEmpty(Object warns, InteropLibrary interop) {
try {
return interop.getArraySize(warns) == 0;
} catch (UnsupportedMessageException e) {
throw CompilerDirectives.shouldNotReachHere(e);
return false;
}
}
return false;
Expand Down
5 changes: 5 additions & 0 deletions test/Base_Tests/src/Semantic/Warnings_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,11 @@ add_specs suite_builder = suite_builder.group "Dataflow Warnings" group_builder-
res2 . should_equal True
Warning.get_all res2 . map .value . should_equal ["WARNING2"]

group_builder.specify "warning & panic" <|
panic_text = Panic.catch Standard.Base.Errors.Common.Type_Error (Warning.set 1 2) caught_panic->
caught_panic.payload.to_text
panic_text . should_equal "Type error: expected `warnings` to be Vector, but got Integer."

main filter=Nothing =
suite = Test.build suite_builder->
add_specs suite_builder
Expand Down
Loading