<commit_before># for our tantrums
my class X::Comp::NYI { ... };
my class X::Comp::Trait { ... };

# Variable traits come here, not in traits.pm, since we declare Variable
# in the setting rather than BOOTSTRAP.

my class Variable {
    has str $.name;
    has str $.scope;
    has $.var is rw;
    has $.block;
    has $.slash;

    # make throwing easier
    submethod throw ( |c ) {
        $*W.throw( self.slash, |c );
    }
}

# "is" traits
multi trait_mod:<is>(Variable:D $v, |c ) {
    $v.throw( 'X::Comp::Trait', 
      type      => 'is',
      subtype   => c.hash.keys[0],
      declaring => ' variable',
      expected  => <TypeObject default dynamic>,
    );
}
multi trait_mod:<is>(Variable:D $v, Mu:U $is ) {
    $v.throw( 'X::Comp::NYI',
      feature => "Variable trait 'is TypeObject'",
    );
}
multi trait_mod:<is>(Variable:D $v, :$default!) {
    # make sure we start with the default if a scalar
    $v.var = $default if $v.var.VAR.WHAT ~~ Scalar;
    nqp::getattr($v.var, $v.var.VAR.WHAT, '$!descriptor').set_default($default);
}
multi trait_mod:<is>(Variable:D $v, :$dynamic!) {
# must be a noop for now, as apparently outer scope lexicals are *always*
# visible with the CALLER:: interface, even if they're *not* marked as
# "is dynamic"
}

# "of" traits
multi trait_mod:<of>(Variable:D $v, |c ) {
    $v.throw( 'X::Comp::Trait', <commit_msg>Make (%@)a is default(42) no longer die<commit_after># for our tantrums
my class X::Comp::NYI { ... };
my class X::Comp::Trait { ... };

# Variable traits come here, not in traits.pm, since we declare Variable
# in the setting rather than BOOTSTRAP.

my class Variable {
    has str $.name;
    has str $.scope;
    has $.var is rw;
    has $.block;
    has $.slash;

    # make throwing easier
    submethod throw ( |c ) {
        $*W.throw( self.slash, |c );
    }
}

# "is" traits
multi trait_mod:<is>(Variable:D $v, |c ) {
    $v.throw( 'X::Comp::Trait', 
      type      => 'is',
      subtype   => c.hash.keys[0],
      declaring => ' variable',
      expected  => <TypeObject default dynamic>,
    );
}
multi trait_mod:<is>(Variable:D $v, Mu:U $is ) {
    $v.throw( 'X::Comp::NYI',
      feature => "Variable trait 'is TypeObject'",
    );
}
multi trait_mod:<is>(Variable:D $v, :$default!) {
    # make sure we start with the default if a scalar
    $v.var = $default if $v.var.VAR.WHAT ~~ Scalar;
    nqp::getattr(
      $v.var,
      $v.var.VAR.WHAT.perl ~~ m/\+/ # we have types mixed in
        ?? $v.var.VAR.WHAT.^mro[1]  # (Hash+{TypedHash}) -> (Hash)
        !! $v.var.VAR.WHAT,
      '$!descriptor',
    ).set_default($default);
}
multi trait_mod:<is>(Variable:D $v, :$dynamic!) {
# must be a noop for now, as apparently outer scope lexicals are *always*
# visible with the CALLER:: interface, even if they're *not* marked as
# "is dynamic"
}

# "of" traits
multi trait_mod:<of>(Variable:D $v, |c ) {
    $v.throw( 'X::Comp::Trait', 
{'fraction_non_alphanumeric': 0.17685439560439561, 'fraction_numerical': 0.001717032967032967, 'mean_word_length': 2.9364864864864866, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5590643', 'n_tokens_mistral': 1067, 'n_tokens_neox': 1045, 'n_words': 304}