Skip to content
  • John Hawthorn's avatar
    70b60d24
    Fix inconsistency with opt_aref_with · 70b60d24
    John Hawthorn authored
    opt_aref_with is an optimized instruction for accessing a Hash using a
    non-frozen string key (ie. from a file without frozen_string_literal).
    It attempts to avoid allocating the string, and instead silently using a
    frozen string (hash string keys are always fstrings).
    
    Because this is just an optimization, it should be invisible to the
    user. However, previously this optimization was could be seen via hashes
    with default procs.
    
    For example, previously:
    
        h = Hash.new { |h, k| k.frozen? }
        str = "foo"
        h[str]   # false
        h["foo"] # true when optimizations enabled
    
    This commit checks that the Hash doesn't have a default proc when using
    opt_aref_with.
    70b60d24
    Fix inconsistency with opt_aref_with
    John Hawthorn authored
    opt_aref_with is an optimized instruction for accessing a Hash using a
    non-frozen string key (ie. from a file without frozen_string_literal).
    It attempts to avoid allocating the string, and instead silently using a
    frozen string (hash string keys are always fstrings).
    
    Because this is just an optimization, it should be invisible to the
    user. However, previously this optimization was could be seen via hashes
    with default procs.
    
    For example, previously:
    
        h = Hash.new { |h, k| k.frozen? }
        str = "foo"
        h[str]   # false
        h["foo"] # true when optimizations enabled
    
    This commit checks that the Hash doesn't have a default proc when using
    opt_aref_with.
Loading