@function exists($name) {
  @return global-variable-exists($name);
}

@function f() {
  $foo: hi;
  @return g();
}

@function g() {
  @return global-variable-exists(foo);
}

$z: hi;

div {
  foo: global-variable-exists(x);    
  foo: global-variable-exists("x");    
  foo: global-variable-exists(z);
  foo: global-variable-exists("z");    

  span {
    $x: false;

    foo: global-variable-exists(x);
    foo: global-variable-exists("x");    
    foo: global-variable-exists(y);
    foo: global-variable-exists("y");    

    foo: global-variable-exists(z);
    foo: global-variable-exists("z");    

    p {
      foo: global-variable-exists(x);
      foo: global-variable-exists("x");    
      foo: exists(x);
      foo: exists("x");    
      foo: global-variable-exists(z);
      foo: global-variable-exists("z");    
      foo: global-variable-exists(y);
      foo: global-variable-exists("y");    
      foo: f();
      $y: blah;
      //TODO: check for shadowing
    }
  }

}
