Skip to content

Commit

Permalink
[ruby/prism] Match CRuby error message for unknown % string
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton authored and matzbot committed May 16, 2024
1 parent 0116688 commit 7a4b9d1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion prism/templates/src/diagnostic.c.erb
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ static const pm_diagnostic_data_t diagnostic_messages[PM_DIAGNOSTIC_ID_MAX] = {
[PM_ERR_INVALID_MULTIBYTE_CHARACTER] = { "invalid multibyte character 0x%X", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_INVALID_MULTIBYTE_ESCAPE] = { "invalid multibyte escape: /%.*s/", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_INVALID_PRINTABLE_CHARACTER] = { "invalid character `%c`", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_INVALID_PERCENT] = { "invalid `%` token", PM_ERROR_LEVEL_SYNTAX }, // TODO WHAT?
[PM_ERR_INVALID_PERCENT] = { "unknown type of %string", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_INVALID_RETRY_AFTER_ELSE] = { "Invalid retry after else", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_INVALID_RETRY_AFTER_ENSURE] = { "Invalid retry after ensure", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_INVALID_RETRY_WITHOUT_RESCUE] = { "Invalid retry without rescue", PM_ERROR_LEVEL_SYNTAX },
Expand Down
4 changes: 2 additions & 2 deletions test/prism/errors_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def test_missing_terminator_in_parentheses

def test_unterminated_argument_expression
assert_errors expression('a %'), 'a %', [
["invalid `%` token", 2..3],
["unknown type of %string", 2..3],
["unexpected end-of-input; expected an expression after the operator", 3..3],
["unexpected end-of-input, assuming it is closing the parent top level context", 3..3]
]
Expand Down Expand Up @@ -1400,7 +1400,7 @@ def test_invalid_number_underscores
end

def test_alnum_delimiters
error_messages = ["invalid `%` token"]
error_messages = ["unknown type of %string"]

assert_error_messages "%qXfooX", error_messages
assert_error_messages "%QXfooX", error_messages
Expand Down

0 comments on commit 7a4b9d1

Please sign in to comment.