mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 02:24:58 +02:00
fix: panic of if command as a constant expr by bringing back Type::Block
(#16122)
Fixes #16110. Alternative to #16120 # Description # User-Facing Changes no more panic # Tests + Formatting +1 # After Submitting
This commit is contained in:
@ -2487,7 +2487,7 @@ pub fn parse_module(
|
||||
working_set,
|
||||
Expr::Block(block_id),
|
||||
block_expr_span,
|
||||
Type::Any,
|
||||
Type::Block,
|
||||
);
|
||||
|
||||
let module_decl_id = working_set
|
||||
|
@ -4768,7 +4768,7 @@ pub fn parse_block_expression(working_set: &mut StateWorkingSet, span: Span) ->
|
||||
|
||||
let block_id = working_set.add_block(Arc::new(output));
|
||||
|
||||
Expression::new(working_set, Expr::Block(block_id), span, Type::Any)
|
||||
Expression::new(working_set, Expr::Block(block_id), span, Type::Block)
|
||||
}
|
||||
|
||||
pub fn parse_match_block_expression(working_set: &mut StateWorkingSet, span: Span) -> Expression {
|
||||
|
@ -88,6 +88,7 @@ pub fn type_compatible(lhs: &Type, rhs: &Type) -> bool {
|
||||
(Type::Int, Type::Number) => true,
|
||||
(Type::Number, Type::Float) => true,
|
||||
(Type::Float, Type::Number) => true,
|
||||
(Type::Closure, Type::Block) => true,
|
||||
(Type::Any, _) => true,
|
||||
(_, Type::Any) => true,
|
||||
(Type::Record(lhs), Type::Record(rhs)) | (Type::Table(lhs), Type::Table(rhs)) => {
|
||||
|
Reference in New Issue
Block a user