mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-02 14:48:15 +00:00
Shell: Make null_or_alternative actually look up the given variable
This commit is contained in:
committed by
Ali Mohammad Pur
parent
1403e56535
commit
367da548ff
@@ -515,9 +515,14 @@ ErrorOr<RefPtr<AST::Node>> Shell::immediate_null_or_alternative(AST::ImmediateEx
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto value = TRY(TRY(const_cast<AST::Node&>(*arguments.first()).run(*this))->resolve_without_cast(*this));
|
||||
auto name = TRY(TRY(const_cast<AST::Node&>(*arguments.first()).run(*this))->resolve_as_string(*this));
|
||||
auto frame = find_frame_containing_local_variable(name);
|
||||
if (!frame)
|
||||
return make_ref_counted<AST::StringLiteral>(invoking_node.position(), ""_short_string, AST::StringLiteral::EnclosureType::None);
|
||||
|
||||
auto value = frame->local_variables.get(name.bytes_as_string_view()).value();
|
||||
if ((value->is_string() && TRY(value->resolve_as_string(*this)).is_empty()) || (value->is_list() && TRY(value->resolve_as_list(*this)).is_empty()))
|
||||
return make_ref_counted<AST::SyntheticNode>(invoking_node.position(), value);
|
||||
return make_ref_counted<AST::SyntheticNode>(invoking_node.position(), *value);
|
||||
|
||||
return arguments.last();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user