mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 08:06:03 +02:00
Remove the Value::Block
case (#12582)
# Description `Value` describes the types of first-class values that users and scripts can create, manipulate, pass around, and store. However, `Block`s are not first-class values in the language, so this PR removes it from `Value`. This removes some unnecessary code, and this change should be invisible to the user except for the change to `scope modules` described below. # User-Facing Changes Breaking change: the output of `scope modules` was changed so that `env_block` is now `has_env_block` which is a boolean value instead of a `Block`. # After Submitting Update the language guide possibly.
This commit is contained in:
@ -276,8 +276,7 @@ pub fn debug_string_without_formatting(value: &Value) -> String {
|
||||
Ok(val) => debug_string_without_formatting(&val),
|
||||
Err(error) => format!("{error:?}"),
|
||||
},
|
||||
//TODO: It would be good to drill in deeper to blocks and closures.
|
||||
Value::Block { val, .. } => format!("<Block {val}>"),
|
||||
//TODO: It would be good to drill deeper into closures.
|
||||
Value::Closure { val, .. } => format!("<Closure {}>", val.block_id),
|
||||
Value::Nothing { .. } => String::new(),
|
||||
Value::Error { error, .. } => format!("{error:?}"),
|
||||
|
@ -173,8 +173,8 @@ impl Command for ViewSource {
|
||||
}
|
||||
}
|
||||
value => {
|
||||
if let Ok(block_id) = value.coerce_block() {
|
||||
let block = engine_state.get_block(block_id);
|
||||
if let Ok(closure) = value.as_closure() {
|
||||
let block = engine_state.get_block(closure.block_id);
|
||||
|
||||
if let Some(span) = block.span {
|
||||
let contents = engine_state.get_span_contents(span);
|
||||
|
Reference in New Issue
Block a user