[PRISM] Respect string encoding override in array literals

Fixes `TestZlibGzipReader#test_gets2`,
`Psych_Unit_Tests#test_spec_explicit_families`, and many failures in
`test_unicode_normalize.rb`.
This commit is contained in:
Alan Wu 2024-02-01 17:11:32 -05:00 committed by GitHub
parent 770b5499a5
commit 8d33be9833
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -405,7 +405,7 @@ pm_static_literal_value(const pm_node_t *node, const pm_scope_node_t *scope_node
return INT2FIX(source_line);
}
case PM_STRING_NODE:
return parse_string(&((pm_string_node_t *) node)->unescaped, parser);
return parse_string_encoded(node, &((pm_string_node_t *)node)->unescaped, parser);
case PM_SYMBOL_NODE:
return ID2SYM(parse_string_symbol((pm_symbol_node_t *)node, parser));
case PM_TRUE_NODE:

View File

@ -834,6 +834,13 @@ module Prism
# Test keyword splat inside of array
assert_prism_eval("[**{x: 'hello'}]")
# Test UTF-8 string array literal in a US-ASCII file
assert_prism_eval(<<~'RUBY', raw: true)
# -*- coding: us-ascii -*-
# frozen_string_literal: true
%W"\u{1f44b} \u{1f409}"
RUBY
end
def test_AssocNode