8000 [PRISM] Support US-ASCII symbols · ruby/ruby@e0fd1b0 · GitHub
[go: up one dir, main page]

Skip to content

Commit e0fd1b0

Browse files
committed
[PRISM] Support US-ASCII symbols
1 parent d3bef1d commit e0fd1b0

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

prism_compile.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ parse_string_symbol(const pm_symbol_node_t *symbol, const pm_parser_t *parser)
216216
else if (symbol->base.flags & PM_SYMBOL_FLAGS_FORCED_BINARY_ENCODING) {
217217
encoding = "ASCII-8BIT";
218218
}
219+
else if (symbol->base.flags & PM_SYMBOL_FLAGS_FORCED_US_ASCII_ENCODING) {
220+
encoding = "US-ASCII";
221+
}
219222
const uint8_t *start = pm_string_source(&symbol->unescaped);
220223
return parse_symbol(start, start + pm_string_length(&symbol->unescaped), encoding);
221224
}

test/ruby/test_compile_prism.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,12 @@ def test_SymbolNode
791791
# -*- coding: us-ascii -*-
792792
:"\xff"
793793
RUBY
794+
795+
# Test US-ASCII symbol in a ASCII-8BIT file
796+
assert_prism_eval(<<~'RUBY', raw: true)
797+
# -*- coding: us-ascii -*-
798+
:a
799+
RUBY
794800
end
795801

796802
def test_XStringNode

0 commit comments

Comments
 (0)
0