gap> x:=1;;
gap> f:=function(a)
>   local g, y, unbound_higher;
>   y:=2;
>   g := function(b)
>      local z, unbound_local;
>      z:=3;
>      Error("breakpoint");
>      return a+b+z;
>   end;
>   return g(10) + y;
> end;;
gap> f(1);
Error, breakpoint at *stdin*:9 called from
g( 10 ) at *stdin*:12 called from
<function "f">( <arguments> )
 called from read-eval loop at *stdin*:14
you can 'quit;' to quit to outer loop, or
you can 'return;' to continue
brk> 
brk> x; # access global
1
brk> Unbind(x);
brk> x:=42;
Syntax warning: Unbound global variable in *errin*:4
x:=42;
^
42
brk> IsBound(x);
true
brk> unbound_global;
Syntax warning: Unbound global variable in *errin*:6
unbound_global;
^^^^^^^^^^^^^^
Error, Variable: 'unbound_global' must have a value in
  Error( "breakpoint" ); at *stdin*:9 called from 
g( 10 ) at *stdin*:12 called from
<function "f">( <arguments> )
 called from read-eval loop at *errin*:6
brk> 
brk> y; # access higher local
2
brk> Unbind(y);
brk> y:=100;
100
brk> IsBound(y);
true
brk> unbound_higher;
Error, Variable: 'unbound_higher' must have an assigned value in
  Error( "breakpoint" ); at *stdin*:9 called from 
g( 10 ) at *stdin*:12 called from
<function "f">( <arguments> )
 called from read-eval loop at *errin*:12
type 'quit;' to quit to outer loop
brk_2> quit;
brk> 
brk> z; # access local
3
brk> Unbind(z);
brk> z:=1000;
1000
brk> IsBound(z);
true
brk> unbound_local;
Error, Variable: 'unbound_local' must have an assigned value in
  Error( "breakpoint" ); at *stdin*:9 called from 
g( 10 ) at *stdin*:12 called from
<function "f">( <arguments> )
 called from read-eval loop at *errin*:17
type 'quit;' to quit to outer loop
brk_2> quit;
brk> 
brk> return;
1111
gap> x;
42
gap> y;
Error, Variable: 'y' must have a value
not in any function at *stdin*:16
gap> 
gap> h:=function(p)
>   local q;
>   Error("foobar");
>   return p;
> end;
function( p ) ... end
gap> f(1);
Error, breakpoint at *stdin*:9 called from
g( 10 ) at *stdin*:12 called from
<function "f">( <arguments> )
 called from read-eval loop at *stdin*:23
you can 'quit;' to quit to outer loop, or
you can 'return;' to continue
brk> h(2);
Error, foobar at *stdin*:20 called from
Error( "breakpoint" ); at *stdin*:9 called from
g( 10 ) at *stdin*:12 called from
<function "f">( <arguments> )
 called from read-eval loop at *errin*:1
you can 'quit;' to quit to outer loop, or
you can 'return;' to continue
brk_2> 
brk_2> y; # access higher local as debug var
2
brk_2> Unbind(y);
brk_2> y:=100;
100
brk_2> IsBound(y);
true
brk_2> unbound_higher;
Error, Variable: <debug-variable-1-4> must have a value in
  Error( "foobar" ); at *stdin*:20 called from 
Error( "breakpoint" ); at *stdin*:9 called from
g( 10 ) at *stdin*:12 called from
<function "f">( <arguments> )
 called from read-eval loop at *errin*:6
brk_2> 
brk_2> # check coding of dvars
brk_2> function() return unbound_higher; end;
Error, Variable: <debug-variable-1-4> cannot be used here in
  <corrupted statement>  called from 
Error( "foobar" ); at *stdin*:20 called from
Error( "breakpoint" ); at *stdin*:9 called from
g( 10 ) at *stdin*:12 called from
<function "f">( <arguments> )
 called from read-eval loop at *errin*:9
brk_2> function() return IsBound(unbound_higher); end;
Error, Variable: <debug-variable-1-4> cannot be used here in
  <corrupted statement>  called from 
Error( "foobar" ); at *stdin*:20 called from
Error( "breakpoint" ); at *stdin*:9 called from
g( 10 ) at *stdin*:12 called from
<function "f">( <arguments> )
 called from read-eval loop at *errin*:10
brk_2> function() Unbind(unbound_higher); end;
Error, Variable: <debug-variable-1-4> cannot be used here in
  <corrupted statement>  called from 
Error( "foobar" ); at *stdin*:20 called from
Error( "breakpoint" ); at *stdin*:9 called from
g( 10 ) at *stdin*:12 called from
<function "f">( <arguments> )
 called from read-eval loop at *errin*:11
brk_2> function() unbound_higher:=0; end;
Error, Variable: <debug-variable-1-4> cannot be used here in
  <corrupted statement>  called from 
Error( "foobar" ); at *stdin*:20 called from
Error( "breakpoint" ); at *stdin*:9 called from
g( 10 ) at *stdin*:12 called from
<function "f">( <arguments> )
 called from read-eval loop at *errin*:12
brk_2> QUIT;
