From e87e580eb3b52042d31746a1d3e0a003b21659d5 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Sun, 1 Nov 2020 13:28:58 +0330 Subject: [PATCH] Shell: Search for variables in the last frame first Otherwise, we'll end up overwriting another frame's variables if the names match up. --- Shell/Shell.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Shell/Shell.cpp b/Shell/Shell.cpp index aff307a27d..8a18f08222 100644 --- a/Shell/Shell.cpp +++ b/Shell/Shell.cpp @@ -359,7 +359,8 @@ String Shell::resolve_path(String path) const Shell::LocalFrame* Shell::find_frame_containing_local_variable(const String& name) { - for (auto& frame : m_local_frames) { + for (size_t i = m_local_frames.size(); i > 0; --i) { + auto& frame = m_local_frames[i - 1]; if (frame.local_variables.contains(name)) return &frame; }