mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:18:11 +00:00
Shell: Make null_or_alternative actually look up the given variable
This commit is contained in:
parent
1403e56535
commit
367da548ff
1 changed files with 7 additions and 2 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue