Skip to content

Commit 178d4f6

Browse files
committed
Update error message for invalid % at EOF
1 parent 8631976 commit 178d4f6

File tree

4 files changed

+4
-2
lines changed

4 files changed

+4
-2
lines changed

config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ errors:
153153
- INVALID_NUMBER_UNDERSCORE_INNER
154154
- INVALID_NUMBER_UNDERSCORE_TRAILING
155155
- INVALID_PERCENT
156+
- INVALID_PERCENT_EOF
156157
- INVALID_PRINTABLE_CHARACTER
157158
- INVALID_RETRY_AFTER_ELSE
158159
- INVALID_RETRY_AFTER_ENSURE

src/prism.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11356,7 +11356,7 @@ parser_lex(pm_parser_t *parser) {
1135611356
// operator because we don't want to move into the string
1135711357
// lex mode unnecessarily.
1135811358
if ((lex_state_beg_p(parser) || lex_state_arg_p(parser)) && (parser->current.end >= parser->end)) {
11359-
pm_parser_err_current(parser, PM_ERR_INVALID_PERCENT);
11359+
pm_parser_err_current(parser, PM_ERR_INVALID_PERCENT_EOF);
1136011360
LEX(PM_TOKEN_PERCENT);
1136111361
}
1136211362

templates/src/diagnostic.c.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ static const pm_diagnostic_data_t diagnostic_messages[PM_DIAGNOSTIC_ID_MAX] = {
236236
[PM_ERR_INVALID_MULTIBYTE_ESCAPE] = { "invalid multibyte escape: /%.*s/", PM_ERROR_LEVEL_SYNTAX },
237237
[PM_ERR_INVALID_PRINTABLE_CHARACTER] = { "invalid character `%c`", PM_ERROR_LEVEL_SYNTAX },
238238
[PM_ERR_INVALID_PERCENT] = { "unknown type of %string", PM_ERROR_LEVEL_SYNTAX },
239+
[PM_ERR_INVALID_PERCENT_EOF] = { "unterminated quoted string meets end of file", PM_ERROR_LEVEL_SYNTAX },
239240
[PM_ERR_INVALID_RETRY_AFTER_ELSE] = { "Invalid retry after else", PM_ERROR_LEVEL_SYNTAX },
240241
[PM_ERR_INVALID_RETRY_AFTER_ENSURE] = { "Invalid retry after ensure", PM_ERROR_LEVEL_SYNTAX },
241242
[PM_ERR_INVALID_RETRY_WITHOUT_RESCUE] = { "Invalid retry without rescue", PM_ERROR_LEVEL_SYNTAX },

test/prism/errors_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def test_missing_terminator_in_parentheses
208208

209209
def test_unterminated_argument_expression
210210
assert_errors expression('a %'), 'a %', [
211-
["unknown type of %string", 2..3],
211+
["unterminated quoted string meets end of file", 2..3],
212212
["unexpected end-of-input; expected an expression after the operator", 3..3],
213213
["unexpected end-of-input, assuming it is closing the parent top level context", 3..3]
214214
]

0 commit comments

Comments
 (0)