From 352332991d0498220b05f8d09c7c73ea04cdd85c Mon Sep 17 00:00:00 2001 From: Michael Lill Date: Fri, 16 Aug 2024 09:58:11 +0200 Subject: [PATCH 1/4] lib: option/outcome, change panic messages also removed some unneeded parentheses. --- lib/num_option.fz | 4 ++-- lib/option.fz | 8 ++++---- lib/outcome.fz | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/num_option.fz b/lib/num_option.fz index 0a0bb0c498..2017117b95 100644 --- a/lib/num_option.fz +++ b/lib/num_option.fz @@ -67,10 +67,10 @@ is # public val T pre - safety: (num_option.this??) + safety: num_option.this?? => num_option.this ? v T => v - | nil => fuzion.std.panic "num_option.val called on nil" + | nil => fuzion.std.panic "You either turned off safety or you discovered a severe compiler bug! This code should be unreachable." # unwrap value or get default diff --git a/lib/option.fz b/lib/option.fz index 56d6cd22f4..ae234a4b91 100644 --- a/lib/option.fz +++ b/lib/option.fz @@ -67,10 +67,10 @@ is # public val T pre - safety: (option.this??) # NYI: REGRESSION: parantheses currently necessary, due to PR #2572 + safety: option.this?? => option.this ? v T => v - | nil => fuzion.std.panic "option.val called on nil" + | nil => fuzion.std.panic "You either turned off safety or you discovered a severe compiler bug! This code should be unreachable." # monadic operator @@ -131,10 +131,10 @@ is # public get pre - safety: (option.this??) + safety: option.this?? => option.this ? v T => v - | nil => fuzion.std.panic "option.get called on nil" + | nil => fuzion.std.panic "You either turned off safety or you discovered a severe compiler bug! This code should be unreachable." # unwraps an option if it exists, returns default value otherwise. diff --git a/lib/outcome.fz b/lib/outcome.fz index 1f669369dc..33097a8116 100644 --- a/lib/outcome.fz +++ b/lib/outcome.fz @@ -88,10 +88,10 @@ is # public val T pre - safety: (outcome.this??) + safety: outcome.this?? => outcome.this ? v T => v - | error => panic "outcome.val called on error" + | error => panic "You either turned off safety or you discovered a severe compiler bug! This code should be unreachable." # value of an outcome or default if outcome contains err @@ -109,9 +109,9 @@ is # public err error pre - safety: (outcome.this!!) + safety: outcome.this!! => - outcome.this ? T => panic "outcome.err called on successful outcome" + outcome.this ? T => panic "You either turned off safety or you discovered a severe compiler bug! This code should be unreachable." | e error => e From 73b1abf3750c4b236fa1a02ace08ba150a21165d Mon Sep 17 00:00:00 2001 From: Michael Lill Date: Mon, 19 Aug 2024 13:40:53 +0200 Subject: [PATCH 2/4] lib: improve _unreachable_ panic messages. --- lib/num_option.fz | 2 +- lib/option.fz | 4 ++-- lib/outcome.fz | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/num_option.fz b/lib/num_option.fz index 2017117b95..b094630519 100644 --- a/lib/num_option.fz +++ b/lib/num_option.fz @@ -70,7 +70,7 @@ is safety: num_option.this?? => num_option.this ? v T => v - | nil => fuzion.std.panic "You either turned off safety or you discovered a severe compiler bug! This code should be unreachable." + | nil => fuzion.std.panic "num_option.val called on nil. You either turned off safety or you discovered a severe compiler bug! This code should be unreachable." # unwrap value or get default diff --git a/lib/option.fz b/lib/option.fz index ae234a4b91..b9057c65fb 100644 --- a/lib/option.fz +++ b/lib/option.fz @@ -70,7 +70,7 @@ is safety: option.this?? => option.this ? v T => v - | nil => fuzion.std.panic "You either turned off safety or you discovered a severe compiler bug! This code should be unreachable." + | nil => fuzion.std.panic "option.val called on nil. You either turned off safety or you discovered a severe compiler bug! This code should be unreachable." # monadic operator @@ -134,7 +134,7 @@ is safety: option.this?? => option.this ? v T => v - | nil => fuzion.std.panic "You either turned off safety or you discovered a severe compiler bug! This code should be unreachable." + | nil => fuzion.std.panic "option.get called on nil. You either turned off safety or you discovered a severe compiler bug! This code should be unreachable." # unwraps an option if it exists, returns default value otherwise. diff --git a/lib/outcome.fz b/lib/outcome.fz index 33097a8116..9f918721af 100644 --- a/lib/outcome.fz +++ b/lib/outcome.fz @@ -91,7 +91,7 @@ is safety: outcome.this?? => outcome.this ? v T => v - | error => panic "You either turned off safety or you discovered a severe compiler bug! This code should be unreachable." + | error => panic "outcome.val called on nil. You either turned off safety or you discovered a severe compiler bug! This code should be unreachable." # value of an outcome or default if outcome contains err @@ -111,7 +111,7 @@ is pre safety: outcome.this!! => - outcome.this ? T => panic "You either turned off safety or you discovered a severe compiler bug! This code should be unreachable." + outcome.this ? T => panic "outcome.err called on successful outcome. You either turned off safety or you discovered a severe compiler bug! This code should be unreachable." | e error => e From 089538e3839595c7d1496129001e559cbc9b6f4d Mon Sep 17 00:00:00 2001 From: Michael Lill Date: Mon, 9 Sep 2024 09:56:38 +0200 Subject: [PATCH 3/4] lib: replace panic text --- lib/num_option.fz | 2 +- lib/option.fz | 4 ++-- lib/outcome.fz | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/num_option.fz b/lib/num_option.fz index b094630519..721d27b326 100644 --- a/lib/num_option.fz +++ b/lib/num_option.fz @@ -70,7 +70,7 @@ is safety: num_option.this?? => num_option.this ? v T => v - | nil => fuzion.std.panic "num_option.val called on nil. You either turned off safety or you discovered a severe compiler bug! This code should be unreachable." + | nil => fuzion.std.panic "num_option.val called on nil. Enable `safety` to obtain a precondition failure for debugging." # unwrap value or get default diff --git a/lib/option.fz b/lib/option.fz index b9057c65fb..e55de858b4 100644 --- a/lib/option.fz +++ b/lib/option.fz @@ -70,7 +70,7 @@ is safety: option.this?? => option.this ? v T => v - | nil => fuzion.std.panic "option.val called on nil. You either turned off safety or you discovered a severe compiler bug! This code should be unreachable." + | nil => fuzion.std.panic "option.val called on nil. Enable `safety` to obtain a precondition failure for debugging." # monadic operator @@ -134,7 +134,7 @@ is safety: option.this?? => option.this ? v T => v - | nil => fuzion.std.panic "option.get called on nil. You either turned off safety or you discovered a severe compiler bug! This code should be unreachable." + | nil => fuzion.std.panic "option.get called on nil. Enable `safety` to obtain a precondition failure for debugging." # unwraps an option if it exists, returns default value otherwise. diff --git a/lib/outcome.fz b/lib/outcome.fz index 9f918721af..a7dea8d8cd 100644 --- a/lib/outcome.fz +++ b/lib/outcome.fz @@ -91,7 +91,7 @@ is safety: outcome.this?? => outcome.this ? v T => v - | error => panic "outcome.val called on nil. You either turned off safety or you discovered a severe compiler bug! This code should be unreachable." + | error => panic "outcome.val called on nil. Enable `safety` to obtain a precondition failure for debugging." # value of an outcome or default if outcome contains err @@ -111,7 +111,7 @@ is pre safety: outcome.this!! => - outcome.this ? T => panic "outcome.err called on successful outcome. You either turned off safety or you discovered a severe compiler bug! This code should be unreachable." + outcome.this ? T => panic "outcome.err called on successful outcome. Enable `safety` to obtain a precondition failure for debugging." | e error => e From eb483e448cddb9c296595e67cb89f1559db574cc Mon Sep 17 00:00:00 2001 From: Michael Lill Date: Mon, 9 Sep 2024 10:02:34 +0200 Subject: [PATCH 4/4] lib: remove, NYI: REGRESSION --- lib/switch.fz | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/switch.fz b/lib/switch.fz index 66cd161f43..4f9de03085 100644 --- a/lib/switch.fz +++ b/lib/switch.fz @@ -68,7 +68,7 @@ is # public get pre - safety: (switch.this??) # NYI: REGRESSION: parantheses currently necessary, due to PR #2572 + safety: switch.this?? => switch.this ? a A => a | B => fuzion.std.panic "switch.get called on B. Enable `safety` to obtain a precondition failure for debugging." @@ -89,7 +89,7 @@ is # public val A pre - safety: (switch.this??) # NYI: REGRESSION: parantheses currently necessary, due to PR #2572 + safety: switch.this?? => switch.this ? a A => a | B => panic "switch.val called on B. Enable `safety` to obtain a precondition failure for debugging."