<commit_before>my class Hash {
    # Has attributes and parent EnumMap declared in BOOTSTRAP
    
    method at_key($key is copy) {
        $key = $key.Str;
        self.exists($key)
          ?? pir::find_method__PPs(EnumMap, 'at_key')(self, $key)
          !! pir::setattribute__0PPsP(my $v, Scalar, '$!whence',
                 -> { pir::find_method__PPs(EnumMap, 'STORE_AT_KEY')(self, $key, $v) } )
    }

    multi method perl(Hash:D \$self:) {
        nqp::iscont($self)
          ?? '{' ~ self.pairs.map({.perl}).join(', ') ~ '}'
          !! '(' ~ self.pairs.map({.perl}).join(', ') ~ ').hash'
    }

    method STORE_AT_KEY(Str \$key, Mu $x is copy) {
        pir::find_method__PPs(EnumMap, 'STORE_AT_KEY')(self, $key, $x);
    }

    method STORE(\$to_store) {
        nqp::bindattr(self, EnumMap, '$!storage', pir::new__Ps('Hash'));
        my $items = $to_store.flat;
        while $items {
            my Mu $x := $items.shift;
            if Enum.ACCEPTS($x) { self.STORE_AT_KEY($x.key.Str, $x.value) }
            elsif EnumMap.ACCEPTS($x) {
                for $x.list { self.STORE_AT_KEY(.key.Str, lvaue) }
            }
            elsif $items { self.STORE_AT_KEY($x.Str, $items.shift) }
            else {
                fail 'Odd number of elements found where hash expected'
            }
        }
        self
    }

}


sub circumfix:<{ }>(*@elems) { my $x = Hash.new.STORE(@elems); }
<commit_msg>Make "Odd number of elements" error a bit stronger, fix Hash.STORE so that %a = %a works (RT #77586).  Probably need a spectest.<commit_after>my class Hash {
    # Has attributes and parent EnumMap declared in BOOTSTRAP
    
    method at_key($key is copy) {
        $key = $key.Str;
        self.exists($key)
          ?? pir::find_method__PPs(EnumMap, 'at_key')(self, $key)
          !! pir::setattribute__0PPsP(my $v, Scalar, '$!whence',
                 -> { pir::find_method__PPs(EnumMap, 'STORE_AT_KEY')(self, $key, $v) } )
    }

    multi method perl(Hash:D \$self:) {
        nqp::iscont($self)
          ?? '{' ~ self.pairs.map({.perl}).join(', ') ~ '}'
          !! '(' ~ self.pairs.map({.perl}).join(', ') ~ ').hash'
    }

    method STORE_AT_KEY(Str \$key, Mu $x is copy) {
        pir::find_method__PPs(EnumMap, 'STORE_AT_KEY')(self, $key, $x);
    }

    method STORE(\$to_store) {
        my $items = $to_store.flat.eager;
        nqp::bindattr(self, EnumMap, '$!storage', pir::new__Ps('Hash'));
        while $items {
            my Mu $x := $items.shift;
            if Enum.ACCEPTS($x) { self.STORE_AT_KEY($x.key.Str, $x.value) }
            elsif EnumMap.ACCEPTS($x) {
                for $x.list { self.STORE_AT_KEY(.key.Str, lvaue) }
            }
            elsif $items { self.STORE_AT_KEY($x.Str, $items.shift) }
            else {
                die 'Odd number of elements found where hash expected'
            }
        }
        self
    }

}


sub circumfix:<{ }>(*@elems) { my $x = Hash.new.STORE(@elems); }

{'fraction_non_alphanumeric': 0.17228590694538098, 'fraction_numerical': 0.0023600809170600135, 'mean_word_length': 2.1035564853556483, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '4776917', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1066, 'n_words': 209}