Loading Ruby.wasm runtime…
Reproduction script
prefix = '\p{In_Arabic}'
suffix = '\p{In_Arabic}'.encode('US-ASCII')
begin
re = /#{prefix}#{suffix}/
regexp_raised = nil
rescue => e
regexp_raised = e.class.name
end
begin
str = "#{prefix}#{suffix}"
string_encoding = str.encoding.name
string_raised = nil
rescue => e
string_encoding = nil
string_raised = e.class.name
end
$result = {
ruby_version: RUBY_VERSION,
regexp_built: regexp_raised.nil?,
regexp_raised: regexp_raised,
string_built: string_raised.nil?,
string_encoding: string_encoding,
string_raised: string_raised,
}
regexp_note =
regexp_raised ? "raised #{regexp_raised} <-- rejected" : 'built'
string_note =
string_raised ? "raised #{string_raised}" : "built, encoding #{string_encoding}"
puts 'Interpolating the same two fragments, one UTF-8 and one US-ASCII:'
puts
puts ' Regexp /#{prefix}#{suffix}/ ' + regexp_note
puts ' String "#{prefix}#{suffix}" ' + string_note
puts
if regexp_raised && string_raised.nil?
puts 'The two forms disagree: Regexp interpolation rejects the mixed'
puts 'encodings that String interpolation silently upgrades.'
else
puts 'The two forms agree on how to combine fragments of different encodings.'
end
puts "Ruby #{RUBY_VERSION}"
Baseline output
Initialising…
(pending)
Fix-candidate output
(no fix candidate yet — bugs.ruby-lang.org#21709 is still open upstream)