$root_default: initial;
$root_implicit: initial;
$root_explicit: initial !global;

@function fn() {
  @if false {
    // nothing
  }
  @elseif true {
    $root_implicit: outer;
    $root_explicit: outer !global;
    $root_default: outer !default;
    $local_implicit: outer;
    $local_explicit: outer !global;
    $local_default: outer !default;
    @if false {
      // nothing
    }
    @else if true {
      $root_implicit: inner;
      $root_explicit: inner !global;
      $root_default: inner !default;
      $local_implicit: inner;
      $local_explicit: inner !global;
      $local_default: inner !default;
    }
  }
  $check_implicit: $root_implicit !global;
  $check_explicit: $root_explicit !global;
  $check_default: $root_default !global;
  @return null;
}

result {
  fn: fn();
  @if variable-exists(outer) {
    outer: $outer;
  }
  @if variable-exists(inner) {
    inner: $inner;
  }
  @if variable-exists(check_implicit) {
    check_implicit: $check_implicit;
  }
  @if variable-exists(check_explicit) {
    check_explicit: $check_explicit;
  }
  @if variable-exists(check_default) {
    check_default: $check_default;
  }
  root_default: $root_default;
  root_implicit: $root_implicit;
  root_explicit: $root_explicit;
  @if variable-exists(local_default) {
    local_default: $local_default;
  }
  @if variable-exists(local_implicit) {
    local_implicit: $local_implicit;
  }
  @if variable-exists(local_explicit) {
    local_explicit: $local_explicit;
  }
}
