Introduce 'Never' type as a safe alternative to always None options
Unfortunately, as documented in: https://github.com/IntersectMBO/cardano-ledger/issues/4571 Some Option fields in the script context certificates are going to remain set to None, at least until the next Hard fork. There's a risk that people permanently lock their funds if they expect deposits on registration credentials to ever be `Some`. So, we introduce a special type that emulate an `Option` that can only ever be `None`. We call it `Never` and it is the first type of this kind (i.e. with constructors indexes not starting at 0).
This commit is contained in:
@@ -16,6 +16,8 @@ pub const LIST: &str = "List";
|
||||
pub const MILLER_LOOP_RESULT: &str = "MillerLoopResult";
|
||||
pub const OPTION: &str = "Option";
|
||||
pub const OPTION_CONSTRUCTORS: &[&str] = &["Some", "None"];
|
||||
pub const NEVER: &str = "Never";
|
||||
pub const NEVER_CONSTRUCTORS: &[&str] = &["__hole", "Never"];
|
||||
pub const ORDERING: &str = "Ordering";
|
||||
pub const ORDERING_CONSTRUCTORS: &[&str] = &["Less", "Equal", "Greater"];
|
||||
pub const PAIR: &str = "Pair";
|
||||
@@ -297,6 +299,17 @@ impl Type {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn never() -> Rc<Type> {
|
||||
Rc::new(Type::App {
|
||||
public: true,
|
||||
contains_opaque: false,
|
||||
name: NEVER.to_string(),
|
||||
module: "".to_string(),
|
||||
args: vec![],
|
||||
alias: None,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn ordering() -> Rc<Type> {
|
||||
Rc::new(Type::App {
|
||||
public: true,
|
||||
|
||||
Reference in New Issue
Block a user