|
if let Some(else_blk) = else_block { |
|
let else_type_id = |
|
if let AstNode::Block(_) = self.compiler.ast_nodes[else_blk.0] { |
|
self.typecheck_block(else_blk, expected) |
|
} else { |
|
self.typecheck_expr(else_blk, expected) |
|
}; |
|
let mut types = HashSet::new(); |
|
types.insert(then_type_id); |
|
types.insert(else_type_id); |
|
self.create_oneof(types) |
|
} else { |
|
// If there's no else block, the if expression is a statement |
|
NONE_TYPE |
|
} |
The comment on the else branch here is wrong since
should resolve the type of $x to oneof<nothing, int>, not nothing. This breaks oneof type semantics that nushell currently uses.
new-nu-parser/src/typechecker.rs
Lines 483 to 497 in 22df7ad
The comment on the else branch here is wrong since
should resolve the type of
$xtooneof<nothing, int>, notnothing. This breaks oneof type semantics that nushell currently uses.