summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2024-02-13 21:38:30 -0500
committerKevin Newton <kddnewton@gmail.com>2024-02-14 13:24:43 -0500
commitfc2c128e7e1fd4a197669d2f04e8457f4188b7f3 (patch)
tree1b93dc6c8633ac9ce06339f9611cc289e7cfbd6c
parent7177731282bea651385818076d4fa6b9bdf717c0 (diff)
[PRISM] Set eval encoding based on string encoding
-rw-r--r--.github/workflows/prism.yml2
-rw-r--r--prism_compile.c4
-rw-r--r--test/.excludes-prism/TestERBCoreWOStrScan.rb1
-rw-r--r--test/.excludes-prism/TestEval.rb2
-rw-r--r--test/.excludes-prism/TestParse.rb4
-rw-r--r--test/.excludes-prism/TestRequire.rb2
-rw-r--r--test/.excludes-prism/TestRubyLiteral.rb1
7 files changed, 8 insertions, 8 deletions
diff --git a/.github/workflows/prism.yml b/.github/workflows/prism.yml
index dd0133d374..3ebccf976e 100644
--- a/.github/workflows/prism.yml
+++ b/.github/workflows/prism.yml
@@ -90,7 +90,7 @@ jobs:
timeout-minutes: 40
env:
GNUMAKEFLAGS: ''
- RUBY_TESTOPTS: '-q --tty=no --excludes-dir="../src/test/.excludes-prism" --exclude="test_ast.rb" --exclude="test_marshal.rb" --exclude="test_regexp.rb" --exclude="error_highlight/test_error_highlight.rb" --exclude="irb/test_context.rb" --exclude="prism/encoding_test.rb" --exclude="prism/unescape_test.rb"'
+ RUBY_TESTOPTS: '-q --tty=no --excludes-dir="../src/test/.excludes-prism" --exclude="test_ast.rb" --exclude="test_regexp.rb" --exclude="error_highlight/test_error_highlight.rb" --exclude="irb/test_context.rb" --exclude="prism/encoding_test.rb" --exclude="prism/unescape_test.rb"'
RUN_OPTS: ${{ matrix.run_opts }}
# - name: make test-spec
diff --git a/prism_compile.c b/prism_compile.c
index 095799db9b..6654929ace 100644
--- a/prism_compile.c
+++ b/prism_compile.c
@@ -8254,6 +8254,10 @@ VALUE
pm_parse_string(pm_parse_result_t *result, VALUE source, VALUE filepath)
{
pm_string_constant_init(&result->input, RSTRING_PTR(source), RSTRING_LEN(source));
+
+ rb_encoding *encoding = rb_enc_get(source);
+ pm_options_encoding_set(&result->options, rb_enc_name(encoding));
+
return pm_parse_input(result, filepath);
}
diff --git a/test/.excludes-prism/TestERBCoreWOStrScan.rb b/test/.excludes-prism/TestERBCoreWOStrScan.rb
index 37f4102601..d90cd5de3a 100644
--- a/test/.excludes-prism/TestERBCoreWOStrScan.rb
+++ b/test/.excludes-prism/TestERBCoreWOStrScan.rb
@@ -2,3 +2,4 @@ exclude(:test_def_method_with_fname, "unknown")
exclude(:test_def_method_without_filename, "unknown")
exclude(:test_keep_lineno, "unknown")
exclude(:test_multi_line_comment_lineno, "unknown")
+exclude(:test_require_nonascii_path_shift_jis, "unknown")
diff --git a/test/.excludes-prism/TestEval.rb b/test/.excludes-prism/TestEval.rb
index e11f30dd5f..a547b89c87 100644
--- a/test/.excludes-prism/TestEval.rb
+++ b/test/.excludes-prism/TestEval.rb
@@ -1,5 +1,3 @@
exclude(:test_eval_ascii_incompatible, "incorrect encoding")
exclude(:test_eval_location_binding, "incorrect line number")
exclude(:test_file_encoding, "incorrect encoding")
-exclude(:test_with_filename_and_safe_level, "incorrect line number")
-exclude(:test_with_filename_lineno, "incorrect line number")
diff --git a/test/.excludes-prism/TestParse.rb b/test/.excludes-prism/TestParse.rb
index 251bb2e3ad..5db342dfb8 100644
--- a/test/.excludes-prism/TestParse.rb
+++ b/test/.excludes-prism/TestParse.rb
@@ -1,7 +1,4 @@
exclude(:test_assign_in_conditional, "missing warning")
-exclude(:test_eval_ascii_incompatible, "unknown")
-exclude(:test_eval_location_binding, "incorrect line number")
-exclude(:test_file_encoding, "unknown")
exclude(:test_here_document, "incorrect heredoc")
exclude(:test_literal_in_conditional, "missing warning")
exclude(:test_magic_comment, "incorrect encoding")
@@ -9,7 +6,6 @@ exclude(:test_negative_line_number, "incorrect line number")
exclude(:test_nonascii_const_set, "incorrect encoding")
exclude(:test_nonascii_constant, "incorrect encoding")
exclude(:test_question, "missing warning")
-exclude(:test_redefinition_mismatch, "unknown")
exclude(:test_serial_comparison, "missing warning")
exclude(:test_shareable_constant_value_nested, "ractor support")
exclude(:test_shareable_constant_value_nonliteral, "ractor support")
diff --git a/test/.excludes-prism/TestRequire.rb b/test/.excludes-prism/TestRequire.rb
index 78997a42b7..a7f66c5d80 100644
--- a/test/.excludes-prism/TestRequire.rb
+++ b/test/.excludes-prism/TestRequire.rb
@@ -1 +1 @@
-exclude(:test_require_nonascii_path_shift_jis, "unknown")
+exclude(:test_require_nonascii_path_shift_jis, "encoding")
diff --git a/test/.excludes-prism/TestRubyLiteral.rb b/test/.excludes-prism/TestRubyLiteral.rb
index 80cfbfc307..44aa0331ca 100644
--- a/test/.excludes-prism/TestRubyLiteral.rb
+++ b/test/.excludes-prism/TestRubyLiteral.rb
@@ -1,4 +1,5 @@
exclude(:test_dregexp, "unknown")
+exclude(:test_dstring_encoding, "incorrect encoding")
exclude(:test_float, "numbered parameters inside evals")
exclude(:test_frozen_string_in_array_literal, "incorrect frozen value")
exclude(:test_hash_duplicated_key, "missing warning")