From 99c0d0a526b9395676666252da692ddfc2f84f7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 13 Oct 2020 22:03:00 +0200 Subject: [PATCH] Fix crash when running `untracevar` with not existing global variable --- CHANGELOG.md | 1 + lib/byebug/commands/untracevar.rb | 2 +- test/commands/untracevar_test.rb | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 039dc2e8c..60342c2f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixed * [#741](https://github.com/deivid-rodriguez/byebug/pull/741): Small consistency issues in help messages. +* [#743](https://github.com/deivid-rodriguez/byebug/pull/743): `untracevar` command crashing when giving a non existent global variable. ### Removed diff --git a/lib/byebug/commands/untracevar.rb b/lib/byebug/commands/untracevar.rb index 96e5161b8..82a588e68 100644 --- a/lib/byebug/commands/untracevar.rb +++ b/lib/byebug/commands/untracevar.rb @@ -29,7 +29,7 @@ def execute untrace_var(:"#{var}") puts pr("trace.messages.undo", var: var) else - errmsg pr("trace.errors.not_global", var: var) + errmsg pr("trace.errors.var_is_not_global", name: var) end end end diff --git a/test/commands/untracevar_test.rb b/test/commands/untracevar_test.rb index 99385fc54..cec3395a3 100644 --- a/test/commands/untracevar_test.rb +++ b/test/commands/untracevar_test.rb @@ -13,5 +13,12 @@ def test_untracevar_help check_output_includes "Stops tracing a global variable." end + + def test_untracevar_not_global + enter "untracevar $foo" + debug_code(minimal_program) + + check_error_includes "'$foo' is not a global variable." + end end end