diff --git a/prism_compile.c b/prism_compile.c index 5ecc69470f9b1c..a53d94f5c2cec3 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -9269,7 +9269,8 @@ pm_parse_process_error(const pm_parse_result_t *result) } } - VALUE error = rb_exc_new(rb_eSyntaxError, pm_buffer_value(&buffer), pm_buffer_length(&buffer)); + VALUE message = rb_enc_str_new(pm_buffer_value(&buffer), pm_buffer_length(&buffer), result->node.encoding); + VALUE error = rb_exc_new_str(rb_eSyntaxError, message); rb_encoding *filepath_encoding = result->node.filepath_encoding != NULL ? result->node.filepath_encoding : rb_utf8_encoding(); VALUE path = rb_enc_str_new((const char *) pm_string_source(filepath), pm_string_length(filepath), filepath_encoding); diff --git a/test/.excludes-prism/TestSyntax.rb b/test/.excludes-prism/TestSyntax.rb index 6e9f51604a370e..0505330b1cc399 100644 --- a/test/.excludes-prism/TestSyntax.rb +++ b/test/.excludes-prism/TestSyntax.rb @@ -1,5 +1,4 @@ exclude(:test_dedented_heredoc_continued_line, "heredoc line continuation dedent calculation") -exclude(:test_error_message_encoding, "syntax error message encoding") exclude(:test_it, "https://github.com/ruby/prism/issues/2323") exclude(:test_numbered_parameter, "should raise syntax error for numbered parameters in inner blocks") exclude(:test_unterminated_heredoc_cr, "quoted \r heredoc terminators should not match \r\n")