aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--prism/diagnostic.c442
-rw-r--r--test/prism/errors_test.rb394
2 files changed, 418 insertions, 418 deletions
diff --git a/prism/diagnostic.c b/prism/diagnostic.c
index 1161dec6be..84278b5e9c 100644
--- a/prism/diagnostic.c
+++ b/prism/diagnostic.c
@@ -5,32 +5,33 @@
*
* When composing an error message, use sentence fragments.
*
- * Try describing the property of the code that caused the error, rather than the rule that is being
- * violated. It may help to use a fragment that completes a sentence beginning, "The parser
- * encountered (a) ...". If appropriate, add a description of the rule violation (or other helpful
- * context) after a semicolon.
+ * Try describing the property of the code that caused the error, rather than
+ * the rule that is being violated. It may help to use a fragment that completes
+ * a sentence beginning, "the parser encountered (a) ...". If appropriate, add a
+ * description of the rule violation (or other helpful context) after a
+ * semicolon.
*
- * For example:, instead of "Control escape sequence cannot be doubled", prefer:
+ * For example:, instead of "control escape sequence cannot be doubled", prefer:
*
- * > "Invalid control escape sequence; control cannot be repeated"
+ * > "invalid control escape sequence; control cannot be repeated"
*
- * In some cases, where the failure is more general or syntax expectations are violated, it may make
- * more sense to use a fragment that completes a sentence beginning, "The parser ...".
+ * In some cases, where the failure is more general or syntax expectations are
+ * violated, it may make more sense to use a fragment that completes a sentence
+ * beginning, "the parser ...".
*
* For example:
*
- * > "Expected an expression after `(`"
- * > "Cannot parse the expression"
- *
+ * > "expected an expression after `(`"
+ * > "cannot parse the expression"
*
* ## Message style guide
*
* - Use articles like "a", "an", and "the" when appropriate.
- * - e.g., prefer "Cannot parse the expression" to "Cannot parse expression".
+ * - e.g., prefer "cannot parse the expression" to "cannot parse expression".
* - Use the common name for tokens and nodes.
* - e.g., prefer "keyword splat" to "assoc splat"
* - e.g., prefer "embedded document" to "embdoc"
- * - Capitalize the initial word of the message.
+ * - Do not capitalize the initial word of the message.
* - Use back ticks around token literals
* - e.g., "Expected a `=>` between the hash key and value"
* - Do not use `.` or other punctuation at the end of the message.
@@ -38,7 +39,6 @@
* - For tokens that can have multiple meanings, reference the token and its meaning.
* - e.g., "`*` splat argument" is clearer and more complete than "splat argument" or "`*` argument"
*
- *
* ## Error names (PM_ERR_*)
*
* - When appropriate, prefer node name to token name.
@@ -51,215 +51,215 @@
* sorted. See PM_ERR_ARGUMENT_NO_FORWARDING_* for an example.
*/
static const char* const diagnostic_messages[PM_DIAGNOSTIC_ID_LEN] = {
- [PM_ERR_ALIAS_ARGUMENT] = "Invalid argument being passed to `alias`; expected a bare word, symbol, constant, or global variable",
- [PM_ERR_AMPAMPEQ_MULTI_ASSIGN] = "Unexpected `&&=` in a multiple assignment",
- [PM_ERR_ARGUMENT_AFTER_BLOCK] = "Unexpected argument after a block argument",
- [PM_ERR_ARGUMENT_AFTER_FORWARDING_ELLIPSES] = "Unexpected argument after `...`",
- [PM_ERR_ARGUMENT_BARE_HASH] = "Unexpected bare hash argument",
- [PM_ERR_ARGUMENT_BLOCK_MULTI] = "Multiple block arguments; only one block is allowed",
- [PM_ERR_ARGUMENT_FORMAL_CLASS] = "Invalid formal argument; formal argument cannot be a class variable",
- [PM_ERR_ARGUMENT_FORMAL_CONSTANT] = "Invalid formal argument; formal argument cannot be a constant",
- [PM_ERR_ARGUMENT_FORMAL_GLOBAL] = "Invalid formal argument; formal argument cannot be a global variable",
- [PM_ERR_ARGUMENT_FORMAL_IVAR] = "Invalid formal argument; formal argument cannot be an instance variable",
- [PM_ERR_ARGUMENT_FORWARDING_UNBOUND] = "Unexpected `...` in an non-parenthesized call",
- [PM_ERR_ARGUMENT_NO_FORWARDING_AMP] = "Unexpected `&` when the parent method is not forwarding",
- [PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES] = "Unexpected `...` when the parent method is not forwarding",
- [PM_ERR_ARGUMENT_NO_FORWARDING_STAR] = "Unexpected `*` when the parent method is not forwarding",
- [PM_ERR_ARGUMENT_SPLAT_AFTER_ASSOC_SPLAT] = "Unexpected `*` splat argument after a `**` keyword splat argument",
- [PM_ERR_ARGUMENT_SPLAT_AFTER_SPLAT] = "Unexpected `*` splat argument after a `*` splat argument",
- [PM_ERR_ARGUMENT_TERM_PAREN] = "Expected a `)` to close the arguments",
- [PM_ERR_ARGUMENT_UNEXPECTED_BLOCK] = "Unexpected `{` after a method call without parenthesis",
- [PM_ERR_ARRAY_ELEMENT] = "Expected an element for the array",
- [PM_ERR_ARRAY_EXPRESSION] = "Expected an expression for the array element",
- [PM_ERR_ARRAY_EXPRESSION_AFTER_STAR] = "Expected an expression after `*` in the array",
- [PM_ERR_ARRAY_SEPARATOR] = "Expected a `,` separator for the array elements",
- [PM_ERR_ARRAY_TERM] = "Expected a `]` to close the array",
- [PM_ERR_BEGIN_LONELY_ELSE] = "Unexpected `else` in `begin` block; a `rescue` clause must precede `else`",
- [PM_ERR_BEGIN_TERM] = "Expected an `end` to close the `begin` statement",
- [PM_ERR_BEGIN_UPCASE_BRACE] = "Expected a `{` after `BEGIN`",
- [PM_ERR_BEGIN_UPCASE_TERM] = "Expected a `}` to close the `BEGIN` statement",
+ [PM_ERR_ALIAS_ARGUMENT] = "invalid argument being passed to `alias`; expected a bare word, symbol, constant, or global variable",
+ [PM_ERR_AMPAMPEQ_MULTI_ASSIGN] = "unexpected `&&=` in a multiple assignment",
+ [PM_ERR_ARGUMENT_AFTER_BLOCK] = "unexpected argument after a block argument",
+ [PM_ERR_ARGUMENT_AFTER_FORWARDING_ELLIPSES] = "unexpected argument after `...`",
+ [PM_ERR_ARGUMENT_BARE_HASH] = "unexpected bare hash argument",
+ [PM_ERR_ARGUMENT_BLOCK_MULTI] = "multiple block arguments; only one block is allowed",
+ [PM_ERR_ARGUMENT_FORMAL_CLASS] = "invalid formal argument; formal argument cannot be a class variable",
+ [PM_ERR_ARGUMENT_FORMAL_CONSTANT] = "invalid formal argument; formal argument cannot be a constant",
+ [PM_ERR_ARGUMENT_FORMAL_GLOBAL] = "invalid formal argument; formal argument cannot be a global variable",
+ [PM_ERR_ARGUMENT_FORMAL_IVAR] = "invalid formal argument; formal argument cannot be an instance variable",
+ [PM_ERR_ARGUMENT_FORWARDING_UNBOUND] = "unexpected `...` in an non-parenthesized call",
+ [PM_ERR_ARGUMENT_NO_FORWARDING_AMP] = "unexpected `&` when the parent method is not forwarding",
+ [PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES] = "unexpected `...` when the parent method is not forwarding",
+ [PM_ERR_ARGUMENT_NO_FORWARDING_STAR] = "unexpected `*` when the parent method is not forwarding",
+ [PM_ERR_ARGUMENT_SPLAT_AFTER_ASSOC_SPLAT] = "unexpected `*` splat argument after a `**` keyword splat argument",
+ [PM_ERR_ARGUMENT_SPLAT_AFTER_SPLAT] = "unexpected `*` splat argument after a `*` splat argument",
+ [PM_ERR_ARGUMENT_TERM_PAREN] = "expected a `)` to close the arguments",
+ [PM_ERR_ARGUMENT_UNEXPECTED_BLOCK] = "unexpected `{` after a method call without parenthesis",
+ [PM_ERR_ARRAY_ELEMENT] = "expected an element for the array",
+ [PM_ERR_ARRAY_EXPRESSION] = "expected an expression for the array element",
+ [PM_ERR_ARRAY_EXPRESSION_AFTER_STAR] = "expected an expression after `*` in the array",
+ [PM_ERR_ARRAY_SEPARATOR] = "expected a `,` separator for the array elements",
+ [PM_ERR_ARRAY_TERM] = "expected a `]` to close the array",
+ [PM_ERR_BEGIN_LONELY_ELSE] = "unexpected `else` in `begin` block; a `rescue` clause must precede `else`",
+ [PM_ERR_BEGIN_TERM] = "expected an `end` to close the `begin` statement",
+ [PM_ERR_BEGIN_UPCASE_BRACE] = "expected a `{` after `BEGIN`",
+ [PM_ERR_BEGIN_UPCASE_TERM] = "expected a `}` to close the `BEGIN` statement",
[PM_ERR_BEGIN_UPCASE_TOPLEVEL] = "BEGIN is permitted only at toplevel",
- [PM_ERR_BLOCK_PARAM_LOCAL_VARIABLE] = "Expected a local variable name in the block parameters",
- [PM_ERR_BLOCK_PARAM_PIPE_TERM] = "Expected the block parameters to end with `|`",
- [PM_ERR_BLOCK_TERM_BRACE] = "Expected a block beginning with `{` to end with `}`",
- [PM_ERR_BLOCK_TERM_END] = "Expected a block beginning with `do` to end with `end`",
- [PM_ERR_CANNOT_PARSE_EXPRESSION] = "Cannot parse the expression",
- [PM_ERR_CANNOT_PARSE_STRING_PART] = "Cannot parse the string part",
- [PM_ERR_CASE_EXPRESSION_AFTER_CASE] = "Expected an expression after `case`",
- [PM_ERR_CASE_EXPRESSION_AFTER_WHEN] = "Expected an expression after `when`",
- [PM_ERR_CASE_MATCH_MISSING_PREDICATE] = "Expected a predicate for a case matching statement",
- [PM_ERR_CASE_MISSING_CONDITIONS] = "Expected a `when` or `in` clause after `case`",
- [PM_ERR_CASE_TERM] = "Expected an `end` to close the `case` statement",
- [PM_ERR_CLASS_IN_METHOD] = "Unexpected class definition in a method body",
- [PM_ERR_CLASS_NAME] = "Expected a constant name after `class`",
- [PM_ERR_CLASS_SUPERCLASS] = "Expected a superclass after `<`",
- [PM_ERR_CLASS_TERM] = "Expected an `end` to close the `class` statement",
- [PM_ERR_CLASS_UNEXPECTED_END] = "Unexpected `end`, expecting ';' or '\n'",
- [PM_ERR_CONDITIONAL_ELSIF_PREDICATE] = "Expected a predicate expression for the `elsif` statement",
- [PM_ERR_CONDITIONAL_IF_PREDICATE] = "Expected a predicate expression for the `if` statement",
- [PM_ERR_CONDITIONAL_PREDICATE_TERM] = "Expected `then` or `;` or '\n'",
- [PM_ERR_CONDITIONAL_TERM] = "Expected an `end` to close the conditional clause",
- [PM_ERR_CONDITIONAL_TERM_ELSE] = "Expected an `end` to close the `else` clause",
- [PM_ERR_CONDITIONAL_UNLESS_PREDICATE] = "Expected a predicate expression for the `unless` statement",
- [PM_ERR_CONDITIONAL_UNTIL_PREDICATE] = "Expected a predicate expression for the `until` statement",
- [PM_ERR_CONDITIONAL_WHILE_PREDICATE] = "Expected a predicate expression for the `while` statement",
- [PM_ERR_CONSTANT_PATH_COLON_COLON_CONSTANT] = "Expected a constant after the `::` operator",
- [PM_ERR_DEF_ENDLESS] = "Could not parse the endless method body",
- [PM_ERR_DEF_ENDLESS_SETTER] = "Invalid method name; a setter method cannot be defined in an endless method definition",
- [PM_ERR_DEF_NAME] = "Expected a method name",
- [PM_ERR_DEF_NAME_AFTER_RECEIVER] = "Expected a method name after the receiver",
- [PM_ERR_DEF_PARAMS_TERM] = "Expected a delimiter to close the parameters",
- [PM_ERR_DEF_PARAMS_TERM_PAREN] = "Expected a `)` to close the parameters",
- [PM_ERR_DEF_RECEIVER] = "Expected a receiver for the method definition",
- [PM_ERR_DEF_RECEIVER_TERM] = "Expected a `.` or `::` after the receiver in a method definition",
- [PM_ERR_DEF_TERM] = "Expected an `end` to close the `def` statement",
- [PM_ERR_DEFINED_EXPRESSION] = "Expected an expression after `defined?`",
- [PM_ERR_EMBDOC_TERM] = "Could not find a terminator for the embedded document",
- [PM_ERR_EMBEXPR_END] = "Expected a `}` to close the embedded expression",
- [PM_ERR_EMBVAR_INVALID] = "Invalid embedded variable",
- [PM_ERR_END_UPCASE_BRACE] = "Expected a `{` after `END`",
- [PM_ERR_END_UPCASE_TERM] = "Expected a `}` to close the `END` statement",
- [PM_ERR_ESCAPE_INVALID_CONTROL] = "Invalid control escape sequence",
- [PM_ERR_ESCAPE_INVALID_CONTROL_REPEAT] = "Invalid control escape sequence; control cannot be repeated",
- [PM_ERR_ESCAPE_INVALID_HEXADECIMAL] = "Invalid hexadecimal escape sequence",
- [PM_ERR_ESCAPE_INVALID_META] = "Invalid meta escape sequence",
- [PM_ERR_ESCAPE_INVALID_META_REPEAT] = "Invalid meta escape sequence; meta cannot be repeated",
- [PM_ERR_ESCAPE_INVALID_UNICODE] = "Invalid Unicode escape sequence",
- [PM_ERR_ESCAPE_INVALID_UNICODE_CM_FLAGS] = "Invalid Unicode escape sequence; Unicode cannot be combined with control or meta flags",
- [PM_ERR_ESCAPE_INVALID_UNICODE_LITERAL] = "Invalid Unicode escape sequence; multiple codepoints are not allowed in a character literal",
- [PM_ERR_ESCAPE_INVALID_UNICODE_LONG] = "Invalid Unicode escape sequence; maximum length is 6 digits",
- [PM_ERR_ESCAPE_INVALID_UNICODE_TERM] = "Invalid Unicode escape sequence; needs closing `}`",
- [PM_ERR_EXPECT_ARGUMENT] = "Expected an argument",
- [PM_ERR_EXPECT_EOL_AFTER_STATEMENT] = "Expected a newline or semicolon after the statement",
- [PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ] = "Expected an expression after `&&=`",
- [PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ] = "Expected an expression after `||=`",
- [PM_ERR_EXPECT_EXPRESSION_AFTER_COMMA] = "Expected an expression after `,`",
- [PM_ERR_EXPECT_EXPRESSION_AFTER_EQUAL] = "Expected an expression after `=`",
- [PM_ERR_EXPECT_EXPRESSION_AFTER_LESS_LESS] = "Expected an expression after `<<`",
- [PM_ERR_EXPECT_EXPRESSION_AFTER_LPAREN] = "Expected an expression after `(`",
- [PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR] = "Expected an expression after the operator",
- [PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT] = "Expected an expression after `*` splat in an argument",
- [PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT_HASH] = "Expected an expression after `**` in a hash",
- [PM_ERR_EXPECT_EXPRESSION_AFTER_STAR] = "Expected an expression after `*`",
- [PM_ERR_EXPECT_IDENT_REQ_PARAMETER] = "Expected an identifier for the required parameter",
- [PM_ERR_EXPECT_LPAREN_REQ_PARAMETER] = "Expected a `(` to start a required parameter",
- [PM_ERR_EXPECT_RBRACKET] = "Expected a matching `]`",
- [PM_ERR_EXPECT_RPAREN] = "Expected a matching `)`",
- [PM_ERR_EXPECT_RPAREN_AFTER_MULTI] = "Expected a `)` after multiple assignment",
- [PM_ERR_EXPECT_RPAREN_REQ_PARAMETER] = "Expected a `)` to end a required parameter",
- [PM_ERR_EXPECT_STRING_CONTENT] = "Expected string content after opening string delimiter",
- [PM_ERR_EXPECT_WHEN_DELIMITER] = "Expected a delimiter after the predicates of a `when` clause",
- [PM_ERR_EXPRESSION_BARE_HASH] = "Unexpected bare hash in expression",
- [PM_ERR_FOR_COLLECTION] = "Expected a collection after the `in` in a `for` statement",
- [PM_ERR_FOR_INDEX] = "Expected an index after `for`",
- [PM_ERR_FOR_IN] = "Expected an `in` after the index in a `for` statement",
- [PM_ERR_FOR_TERM] = "Expected an `end` to close the `for` loop",
- [PM_ERR_HASH_EXPRESSION_AFTER_LABEL] = "Expected an expression after the label in a hash",
- [PM_ERR_HASH_KEY] = "Expected a key in the hash literal",
- [PM_ERR_HASH_ROCKET] = "Expected a `=>` between the hash key and value",
- [PM_ERR_HASH_TERM] = "Expected a `}` to close the hash literal",
- [PM_ERR_HASH_VALUE] = "Expected a value in the hash literal",
- [PM_ERR_HEREDOC_TERM] = "Could not find a terminator for the heredoc",
- [PM_ERR_INCOMPLETE_QUESTION_MARK] = "Incomplete expression at `?`",
- [PM_ERR_INCOMPLETE_VARIABLE_CLASS] = "Incomplete class variable",
- [PM_ERR_INCOMPLETE_VARIABLE_INSTANCE] = "Incomplete instance variable",
- [PM_ERR_INVALID_ENCODING_MAGIC_COMMENT] = "Unknown or invalid encoding in the magic comment",
- [PM_ERR_INVALID_FLOAT_EXPONENT] = "Invalid exponent",
- [PM_ERR_INVALID_NUMBER_BINARY] = "Invalid binary number",
- [PM_ERR_INVALID_NUMBER_DECIMAL] = "Invalid decimal number",
- [PM_ERR_INVALID_NUMBER_HEXADECIMAL] = "Invalid hexadecimal number",
- [PM_ERR_INVALID_NUMBER_OCTAL] = "Invalid octal number",
- [PM_ERR_INVALID_NUMBER_UNDERSCORE] = "Invalid underscore placement in number",
- [PM_ERR_INVALID_PERCENT] = "Invalid `%` token", // TODO WHAT?
- [PM_ERR_INVALID_TOKEN] = "Invalid token", // TODO WHAT?
- [PM_ERR_INVALID_VARIABLE_GLOBAL] = "Invalid global variable",
- [PM_ERR_LAMBDA_OPEN] = "Expected a `do` keyword or a `{` to open the lambda block",
- [PM_ERR_LAMBDA_TERM_BRACE] = "Expected a lambda block beginning with `{` to end with `}`",
- [PM_ERR_LAMBDA_TERM_END] = "Expected a lambda block beginning with `do` to end with `end`",
- [PM_ERR_LIST_I_LOWER_ELEMENT] = "Expected a symbol in a `%i` list",
- [PM_ERR_LIST_I_LOWER_TERM] = "Expected a closing delimiter for the `%i` list",
- [PM_ERR_LIST_I_UPPER_ELEMENT] = "Expected a symbol in a `%I` list",
- [PM_ERR_LIST_I_UPPER_TERM] = "Expected a closing delimiter for the `%I` list",
- [PM_ERR_LIST_W_LOWER_ELEMENT] = "Expected a string in a `%w` list",
- [PM_ERR_LIST_W_LOWER_TERM] = "Expected a closing delimiter for the `%w` list",
- [PM_ERR_LIST_W_UPPER_ELEMENT] = "Expected a string in a `%W` list",
- [PM_ERR_LIST_W_UPPER_TERM] = "Expected a closing delimiter for the `%W` list",
- [PM_ERR_MALLOC_FAILED] = "Failed to allocate memory",
- [PM_ERR_MODULE_IN_METHOD] = "Unexpected module definition in a method body",
- [PM_ERR_MODULE_NAME] = "Expected a constant name after `module`",
- [PM_ERR_MODULE_TERM] = "Expected an `end` to close the `module` statement",
- [PM_ERR_MULTI_ASSIGN_MULTI_SPLATS] = "Multiple splats in multiple assignment",
- [PM_ERR_NOT_EXPRESSION] = "Expected an expression after `not`",
- [PM_ERR_NUMBER_LITERAL_UNDERSCORE] = "Number literal ending with a `_`",
- [PM_ERR_NUMBERED_PARAMETER_NOT_ALLOWED] = "Numbered parameters are not allowed alongside explicit parameters",
- [PM_ERR_NUMBERED_PARAMETER_OUTER_SCOPE] = "Numbered parameter is already used in outer scope",
- [PM_ERR_OPERATOR_MULTI_ASSIGN] = "Unexpected operator for a multiple assignment",
- [PM_ERR_OPERATOR_WRITE_ARGUMENTS] = "Unexpected operator after a call with arguments",
- [PM_ERR_OPERATOR_WRITE_BLOCK] = "Unexpected operator after a call with a block",
- [PM_ERR_PARAMETER_ASSOC_SPLAT_MULTI] = "Unexpected multiple `**` splat parameters",
- [PM_ERR_PARAMETER_BLOCK_MULTI] = "Multiple block parameters; only one block is allowed",
- [PM_ERR_PARAMETER_METHOD_NAME] = "Unexpected name for a parameter",
- [PM_ERR_PARAMETER_NAME_REPEAT] = "Repeated parameter name",
- [PM_ERR_PARAMETER_NO_DEFAULT] = "Expected a default value for the parameter",
- [PM_ERR_PARAMETER_NO_DEFAULT_KW] = "Expected a default value for the keyword parameter",
+ [PM_ERR_BLOCK_PARAM_LOCAL_VARIABLE] = "expected a local variable name in the block parameters",
+ [PM_ERR_BLOCK_PARAM_PIPE_TERM] = "expected the block parameters to end with `|`",
+ [PM_ERR_BLOCK_TERM_BRACE] = "expected a block beginning with `{` to end with `}`",
+ [PM_ERR_BLOCK_TERM_END] = "expected a block beginning with `do` to end with `end`",
+ [PM_ERR_CANNOT_PARSE_EXPRESSION] = "cannot parse the expression",
+ [PM_ERR_CANNOT_PARSE_STRING_PART] = "cannot parse the string part",
+ [PM_ERR_CASE_EXPRESSION_AFTER_CASE] = "expected an expression after `case`",
+ [PM_ERR_CASE_EXPRESSION_AFTER_WHEN] = "expected an expression after `when`",
+ [PM_ERR_CASE_MATCH_MISSING_PREDICATE] = "expected a predicate for a case matching statement",
+ [PM_ERR_CASE_MISSING_CONDITIONS] = "expected a `when` or `in` clause after `case`",
+ [PM_ERR_CASE_TERM] = "expected an `end` to close the `case` statement",
+ [PM_ERR_CLASS_IN_METHOD] = "unexpected class definition in a method body",
+ [PM_ERR_CLASS_NAME] = "expected a constant name after `class`",
+ [PM_ERR_CLASS_SUPERCLASS] = "expected a superclass after `<`",
+ [PM_ERR_CLASS_TERM] = "expected an `end` to close the `class` statement",
+ [PM_ERR_CLASS_UNEXPECTED_END] = "unexpected `end`, expecting ';' or '\n'",
+ [PM_ERR_CONDITIONAL_ELSIF_PREDICATE] = "expected a predicate expression for the `elsif` statement",
+ [PM_ERR_CONDITIONAL_IF_PREDICATE] = "expected a predicate expression for the `if` statement",
+ [PM_ERR_CONDITIONAL_PREDICATE_TERM] = "expected `then` or `;` or '\n'",
+ [PM_ERR_CONDITIONAL_TERM] = "expected an `end` to close the conditional clause",
+ [PM_ERR_CONDITIONAL_TERM_ELSE] = "expected an `end` to close the `else` clause",
+ [PM_ERR_CONDITIONAL_UNLESS_PREDICATE] = "expected a predicate expression for the `unless` statement",
+ [PM_ERR_CONDITIONAL_UNTIL_PREDICATE] = "expected a predicate expression for the `until` statement",
+ [PM_ERR_CONDITIONAL_WHILE_PREDICATE] = "expected a predicate expression for the `while` statement",
+ [PM_ERR_CONSTANT_PATH_COLON_COLON_CONSTANT] = "expected a constant after the `::` operator",
+ [PM_ERR_DEF_ENDLESS] = "could not parse the endless method body",
+ [PM_ERR_DEF_ENDLESS_SETTER] = "invalid method name; a setter method cannot be defined in an endless method definition",
+ [PM_ERR_DEF_NAME] = "expected a method name",
+ [PM_ERR_DEF_NAME_AFTER_RECEIVER] = "expected a method name after the receiver",
+ [PM_ERR_DEF_PARAMS_TERM] = "expected a delimiter to close the parameters",
+ [PM_ERR_DEF_PARAMS_TERM_PAREN] = "expected a `)` to close the parameters",
+ [PM_ERR_DEF_RECEIVER] = "expected a receiver for the method definition",
+ [PM_ERR_DEF_RECEIVER_TERM] = "expected a `.` or `::` after the receiver in a method definition",
+ [PM_ERR_DEF_TERM] = "expected an `end` to close the `def` statement",
+ [PM_ERR_DEFINED_EXPRESSION] = "expected an expression after `defined?`",
+ [PM_ERR_EMBDOC_TERM] = "could not find a terminator for the embedded document",
+ [PM_ERR_EMBEXPR_END] = "expected a `}` to close the embedded expression",
+ [PM_ERR_EMBVAR_INVALID] = "invalid embedded variable",
+ [PM_ERR_END_UPCASE_BRACE] = "expected a `{` after `END`",
+ [PM_ERR_END_UPCASE_TERM] = "expected a `}` to close the `END` statement",
+ [PM_ERR_ESCAPE_INVALID_CONTROL] = "invalid control escape sequence",
+ [PM_ERR_ESCAPE_INVALID_CONTROL_REPEAT] = "invalid control escape sequence; control cannot be repeated",
+ [PM_ERR_ESCAPE_INVALID_HEXADECIMAL] = "invalid hexadecimal escape sequence",
+ [PM_ERR_ESCAPE_INVALID_META] = "invalid meta escape sequence",
+ [PM_ERR_ESCAPE_INVALID_META_REPEAT] = "invalid meta escape sequence; meta cannot be repeated",
+ [PM_ERR_ESCAPE_INVALID_UNICODE] = "invalid Unicode escape sequence",
+ [PM_ERR_ESCAPE_INVALID_UNICODE_CM_FLAGS] = "invalid Unicode escape sequence; Unicode cannot be combined with control or meta flags",
+ [PM_ERR_ESCAPE_INVALID_UNICODE_LITERAL] = "invalid Unicode escape sequence; multiple codepoints are not allowed in a character literal",
+ [PM_ERR_ESCAPE_INVALID_UNICODE_LONG] = "invalid Unicode escape sequence; maximum length is 6 digits",
+ [PM_ERR_ESCAPE_INVALID_UNICODE_TERM] = "invalid Unicode escape sequence; needs closing `}`",
+ [PM_ERR_EXPECT_ARGUMENT] = "expected an argument",
+ [PM_ERR_EXPECT_EOL_AFTER_STATEMENT] = "expected a newline or semicolon after the statement",
+ [PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ] = "expected an expression after `&&=`",
+ [PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ] = "expected an expression after `||=`",
+ [PM_ERR_EXPECT_EXPRESSION_AFTER_COMMA] = "expected an expression after `,`",
+ [PM_ERR_EXPECT_EXPRESSION_AFTER_EQUAL] = "expected an expression after `=`",
+ [PM_ERR_EXPECT_EXPRESSION_AFTER_LESS_LESS] = "expected an expression after `<<`",
+ [PM_ERR_EXPECT_EXPRESSION_AFTER_LPAREN] = "expected an expression after `(`",
+ [PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR] = "expected an expression after the operator",
+ [PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT] = "expected an expression after `*` splat in an argument",
+ [PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT_HASH] = "expected an expression after `**` in a hash",
+ [PM_ERR_EXPECT_EXPRESSION_AFTER_STAR] = "expected an expression after `*`",
+ [PM_ERR_EXPECT_IDENT_REQ_PARAMETER] = "expected an identifier for the required parameter",
+ [PM_ERR_EXPECT_LPAREN_REQ_PARAMETER] = "expected a `(` to start a required parameter",
+ [PM_ERR_EXPECT_RBRACKET] = "expected a matching `]`",
+ [PM_ERR_EXPECT_RPAREN] = "expected a matching `)`",
+ [PM_ERR_EXPECT_RPAREN_AFTER_MULTI] = "expected a `)` after multiple assignment",
+ [PM_ERR_EXPECT_RPAREN_REQ_PARAMETER] = "expected a `)` to end a required parameter",
+ [PM_ERR_EXPECT_STRING_CONTENT] = "expected string content after opening string delimiter",
+ [PM_ERR_EXPECT_WHEN_DELIMITER] = "expected a delimiter after the predicates of a `when` clause",
+ [PM_ERR_EXPRESSION_BARE_HASH] = "unexpected bare hash in expression",
+ [PM_ERR_FOR_COLLECTION] = "expected a collection after the `in` in a `for` statement",
+ [PM_ERR_FOR_INDEX] = "expected an index after `for`",
+ [PM_ERR_FOR_IN] = "expected an `in` after the index in a `for` statement",
+ [PM_ERR_FOR_TERM] = "expected an `end` to close the `for` loop",
+ [PM_ERR_HASH_EXPRESSION_AFTER_LABEL] = "expected an expression after the label in a hash",
+ [PM_ERR_HASH_KEY] = "expected a key in the hash literal",
+ [PM_ERR_HASH_ROCKET] = "expected a `=>` between the hash key and value",
+ [PM_ERR_HASH_TERM] = "expected a `}` to close the hash literal",
+ [PM_ERR_HASH_VALUE] = "expected a value in the hash literal",
+ [PM_ERR_HEREDOC_TERM] = "could not find a terminator for the heredoc",
+ [PM_ERR_INCOMPLETE_QUESTION_MARK] = "incomplete expression at `?`",
+ [PM_ERR_INCOMPLETE_VARIABLE_CLASS] = "incomplete class variable",
+ [PM_ERR_INCOMPLETE_VARIABLE_INSTANCE] = "incomplete instance variable",
+ [PM_ERR_INVALID_ENCODING_MAGIC_COMMENT] = "unknown or invalid encoding in the magic comment",
+ [PM_ERR_INVALID_FLOAT_EXPONENT] = "invalid exponent",
+ [PM_ERR_INVALID_NUMBER_BINARY] = "invalid binary number",
+ [PM_ERR_INVALID_NUMBER_DECIMAL] = "invalid decimal number",
+ [PM_ERR_INVALID_NUMBER_HEXADECIMAL] = "invalid hexadecimal number",
+ [PM_ERR_INVALID_NUMBER_OCTAL] = "invalid octal number",
+ [PM_ERR_INVALID_NUMBER_UNDERSCORE] = "invalid underscore placement in number",
+ [PM_ERR_INVALID_PERCENT] = "invalid `%` token", // TODO WHAT?
+ [PM_ERR_INVALID_TOKEN] = "invalid token", // TODO WHAT?
+ [PM_ERR_INVALID_VARIABLE_GLOBAL] = "invalid global variable",
+ [PM_ERR_LAMBDA_OPEN] = "expected a `do` keyword or a `{` to open the lambda block",
+ [PM_ERR_LAMBDA_TERM_BRACE] = "expected a lambda block beginning with `{` to end with `}`",
+ [PM_ERR_LAMBDA_TERM_END] = "expected a lambda block beginning with `do` to end with `end`",
+ [PM_ERR_LIST_I_LOWER_ELEMENT] = "expected a symbol in a `%i` list",
+ [PM_ERR_LIST_I_LOWER_TERM] = "expected a closing delimiter for the `%i` list",
+ [PM_ERR_LIST_I_UPPER_ELEMENT] = "expected a symbol in a `%I` list",
+ [PM_ERR_LIST_I_UPPER_TERM] = "expected a closing delimiter for the `%I` list",
+ [PM_ERR_LIST_W_LOWER_ELEMENT] = "expected a string in a `%w` list",
+ [PM_ERR_LIST_W_LOWER_TERM] = "expected a closing delimiter for the `%w` list",
+ [PM_ERR_LIST_W_UPPER_ELEMENT] = "expected a string in a `%W` list",
+ [PM_ERR_LIST_W_UPPER_TERM] = "expected a closing delimiter for the `%W` list",
+ [PM_ERR_MALLOC_FAILED] = "failed to allocate memory",
+ [PM_ERR_MODULE_IN_METHOD] = "unexpected module definition in a method body",
+ [PM_ERR_MODULE_NAME] = "expected a constant name after `module`",
+ [PM_ERR_MODULE_TERM] = "expected an `end` to close the `module` statement",
+ [PM_ERR_MULTI_ASSIGN_MULTI_SPLATS] = "multiple splats in multiple assignment",
+ [PM_ERR_NOT_EXPRESSION] = "expected an expression after `not`",
+ [PM_ERR_NUMBER_LITERAL_UNDERSCORE] = "number literal ending with a `_`",
+ [PM_ERR_NUMBERED_PARAMETER_NOT_ALLOWED] = "numbered parameters are not allowed alongside explicit parameters",
+ [PM_ERR_NUMBERED_PARAMETER_OUTER_SCOPE] = "numbered parameter is already used in outer scope",
+ [PM_ERR_OPERATOR_MULTI_ASSIGN] = "unexpected operator for a multiple assignment",
+ [PM_ERR_OPERATOR_WRITE_ARGUMENTS] = "unexpected operator after a call with arguments",
+ [PM_ERR_OPERATOR_WRITE_BLOCK] = "unexpected operator after a call with a block",
+ [PM_ERR_PARAMETER_ASSOC_SPLAT_MULTI] = "unexpected multiple `**` splat parameters",
+ [PM_ERR_PARAMETER_BLOCK_MULTI] = "multiple block parameters; only one block is allowed",
+ [PM_ERR_PARAMETER_METHOD_NAME] = "unexpected name for a parameter",
+ [PM_ERR_PARAMETER_NAME_REPEAT] = "repeated parameter name",
+ [PM_ERR_PARAMETER_NO_DEFAULT] = "expected a default value for the parameter",
+ [PM_ERR_PARAMETER_NO_DEFAULT_KW] = "expected a default value for the keyword parameter",
[PM_ERR_PARAMETER_NUMBERED_RESERVED] = "%.2s is reserved for a numbered parameter",
- [PM_ERR_PARAMETER_ORDER] = "Unexpected parameter order",
- [PM_ERR_PARAMETER_SPLAT_MULTI] = "Unexpected multiple `*` splat parameters",
- [PM_ERR_PARAMETER_STAR] = "Unexpected parameter `*`",
- [PM_ERR_PARAMETER_UNEXPECTED_FWD] = "Unexpected `...` in parameters",
- [PM_ERR_PARAMETER_WILD_LOOSE_COMMA] = "Unexpected `,` in parameters",
- [PM_ERR_PATTERN_EXPRESSION_AFTER_BRACKET] = "Expected a pattern expression after the `[` operator",
- [PM_ERR_PATTERN_EXPRESSION_AFTER_COMMA] = "Expected a pattern expression after `,`",
- [PM_ERR_PATTERN_EXPRESSION_AFTER_HROCKET] = "Expected a pattern expression after `=>`",
- [PM_ERR_PATTERN_EXPRESSION_AFTER_IN] = "Expected a pattern expression after the `in` keyword",
- [PM_ERR_PATTERN_EXPRESSION_AFTER_KEY] = "Expected a pattern expression after the key",
- [PM_ERR_PATTERN_EXPRESSION_AFTER_PAREN] = "Expected a pattern expression after the `(` operator",
- [PM_ERR_PATTERN_EXPRESSION_AFTER_PIN] = "Expected a pattern expression after the `^` pin operator",
- [PM_ERR_PATTERN_EXPRESSION_AFTER_PIPE] = "Expected a pattern expression after the `|` operator",
- [PM_ERR_PATTERN_EXPRESSION_AFTER_RANGE] = "Expected a pattern expression after the range operator",
- [PM_ERR_PATTERN_HASH_KEY] = "Expected a key in the hash pattern",
- [PM_ERR_PATTERN_HASH_KEY_LABEL] = "Expected a label as the key in the hash pattern", // TODO // THIS // AND // ABOVE // IS WEIRD
- [PM_ERR_PATTERN_IDENT_AFTER_HROCKET] = "Expected an identifier after the `=>` operator",
- [PM_ERR_PATTERN_LABEL_AFTER_COMMA] = "Expected a label after the `,` in the hash pattern",
- [PM_ERR_PATTERN_REST] = "Unexpected rest pattern",
- [PM_ERR_PATTERN_TERM_BRACE] = "Expected a `}` to close the pattern expression",
- [PM_ERR_PATTERN_TERM_BRACKET] = "Expected a `]` to close the pattern expression",
- [PM_ERR_PATTERN_TERM_PAREN] = "Expected a `)` to close the pattern expression",
- [PM_ERR_PIPEPIPEEQ_MULTI_ASSIGN] = "Unexpected `||=` in a multiple assignment",
- [PM_ERR_REGEXP_TERM] = "Expected a closing delimiter for the regular expression",
- [PM_ERR_RESCUE_EXPRESSION] = "Expected a rescued expression",
- [PM_ERR_RESCUE_MODIFIER_VALUE] = "Expected a value after the `rescue` modifier",
- [PM_ERR_RESCUE_TERM] = "Expected a closing delimiter for the `rescue` clause",
- [PM_ERR_RESCUE_VARIABLE] = "Expected an exception variable after `=>` in a rescue statement",
- [PM_ERR_RETURN_INVALID] = "Invalid `return` in a class or module body",
- [PM_ERR_STATEMENT_ALIAS] = "Unexpected an `alias` at a non-statement position",
- [PM_ERR_STATEMENT_POSTEXE_END] = "Unexpected an `END` at a non-statement position",
- [PM_ERR_STATEMENT_PREEXE_BEGIN] = "Unexpected a `BEGIN` at a non-statement position",
- [PM_ERR_STATEMENT_UNDEF] = "Unexpected an `undef` at a non-statement position",
- [PM_ERR_STRING_CONCATENATION] = "Expected a string for concatenation",
- [PM_ERR_STRING_INTERPOLATED_TERM] = "Expected a closing delimiter for the interpolated string",
- [PM_ERR_STRING_LITERAL_TERM] = "Expected a closing delimiter for the string literal",
- [PM_ERR_SYMBOL_INVALID] = "Invalid symbol", // TODO expected symbol? prism.c ~9719
- [PM_ERR_SYMBOL_TERM_DYNAMIC] = "Expected a closing delimiter for the dynamic symbol",
- [PM_ERR_SYMBOL_TERM_INTERPOLATED] = "Expected a closing delimiter for the interpolated symbol",
- [PM_ERR_TERNARY_COLON] = "Expected a `:` after the true expression of a ternary operator",
- [PM_ERR_TERNARY_EXPRESSION_FALSE] = "Expected an expression after `:` in the ternary operator",
- [PM_ERR_TERNARY_EXPRESSION_TRUE] = "Expected an expression after `?` in the ternary operator",
- [PM_ERR_UNDEF_ARGUMENT] = "Invalid argument being passed to `undef`; expected a bare word, constant, or symbol argument",
- [PM_ERR_UNARY_RECEIVER_BANG] = "Expected a receiver for unary `!`",
- [PM_ERR_UNARY_RECEIVER_MINUS] = "Expected a receiver for unary `-`",
- [PM_ERR_UNARY_RECEIVER_PLUS] = "Expected a receiver for unary `+`",
- [PM_ERR_UNARY_RECEIVER_TILDE] = "Expected a receiver for unary `~`",
- [PM_ERR_UNTIL_TERM] = "Expected an `end` to close the `until` statement",
- [PM_ERR_VOID_EXPRESSION] = "Unexpected void value expression",
- [PM_ERR_WHILE_TERM] = "Expected an `end` to close the `while` statement",
- [PM_ERR_WRITE_TARGET_READONLY] = "Immutable variable as a write target",
- [PM_ERR_WRITE_TARGET_UNEXPECTED] = "Unexpected write target",
- [PM_ERR_XSTRING_TERM] = "Expected a closing delimiter for the `%x` or backtick string",
- [PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_MINUS] = "Ambiguous first argument; put parentheses or a space even after `-` operator",
- [PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_PLUS] = "Ambiguous first argument; put parentheses or a space even after `+` operator",
- [PM_WARN_AMBIGUOUS_PREFIX_STAR] = "Ambiguous `*` has been interpreted as an argument prefix",
- [PM_WARN_AMBIGUOUS_SLASH] = "Ambiguous `/`; wrap regexp in parentheses or add a space after `/` operator",
+ [PM_ERR_PARAMETER_ORDER] = "unexpected parameter order",
+ [PM_ERR_PARAMETER_SPLAT_MULTI] = "unexpected multiple `*` splat parameters",
+ [PM_ERR_PARAMETER_STAR] = "unexpected parameter `*`",
+ [PM_ERR_PARAMETER_UNEXPECTED_FWD] = "unexpected `...` in parameters",
+ [PM_ERR_PARAMETER_WILD_LOOSE_COMMA] = "unexpected `,` in parameters",
+ [PM_ERR_PATTERN_EXPRESSION_AFTER_BRACKET] = "expected a pattern expression after the `[` operator",
+ [PM_ERR_PATTERN_EXPRESSION_AFTER_COMMA] = "expected a pattern expression after `,`",
+ [PM_ERR_PATTERN_EXPRESSION_AFTER_HROCKET] = "expected a pattern expression after `=>`",
+ [PM_ERR_PATTERN_EXPRESSION_AFTER_IN] = "expected a pattern expression after the `in` keyword",
+ [PM_ERR_PATTERN_EXPRESSION_AFTER_KEY] = "expected a pattern expression after the key",
+ [PM_ERR_PATTERN_EXPRESSION_AFTER_PAREN] = "expected a pattern expression after the `(` operator",
+ [PM_ERR_PATTERN_EXPRESSION_AFTER_PIN] = "expected a pattern expression after the `^` pin operator",
+ [PM_ERR_PATTERN_EXPRESSION_AFTER_PIPE] = "expected a pattern expression after the `|` operator",
+ [PM_ERR_PATTERN_EXPRESSION_AFTER_RANGE] = "expected a pattern expression after the range operator",
+ [PM_ERR_PATTERN_HASH_KEY] = "expected a key in the hash pattern",
+ [PM_ERR_PATTERN_HASH_KEY_LABEL] = "expected a label as the key in the hash pattern", // TODO // THIS // AND // ABOVE // IS WEIRD
+ [PM_ERR_PATTERN_IDENT_AFTER_HROCKET] = "expected an identifier after the `=>` operator",
+ [PM_ERR_PATTERN_LABEL_AFTER_COMMA] = "expected a label after the `,` in the hash pattern",
+ [PM_ERR_PATTERN_REST] = "unexpected rest pattern",
+ [PM_ERR_PATTERN_TERM_BRACE] = "expected a `}` to close the pattern expression",
+ [PM_ERR_PATTERN_TERM_BRACKET] = "expected a `]` to close the pattern expression",
+ [PM_ERR_PATTERN_TERM_PAREN] = "expected a `)` to close the pattern expression",
+ [PM_ERR_PIPEPIPEEQ_MULTI_ASSIGN] = "unexpected `||=` in a multiple assignment",
+ [PM_ERR_REGEXP_TERM] = "expected a closing delimiter for the regular expression",
+ [PM_ERR_RESCUE_EXPRESSION] = "expected a rescued expression",
+ [PM_ERR_RESCUE_MODIFIER_VALUE] = "expected a value after the `rescue` modifier",
+ [PM_ERR_RESCUE_TERM] = "expected a closing delimiter for the `rescue` clause",
+ [PM_ERR_RESCUE_VARIABLE] = "expected an exception variable after `=>` in a rescue statement",
+ [PM_ERR_RETURN_INVALID] = "invalid `return` in a class or module body",
+ [PM_ERR_STATEMENT_ALIAS] = "unexpected an `alias` at a non-statement position",
+ [PM_ERR_STATEMENT_POSTEXE_END] = "unexpected an `END` at a non-statement position",
+ [PM_ERR_STATEMENT_PREEXE_BEGIN] = "unexpected a `BEGIN` at a non-statement position",
+ [PM_ERR_STATEMENT_UNDEF] = "unexpected an `undef` at a non-statement position",
+ [PM_ERR_STRING_CONCATENATION] = "expected a string for concatenation",
+ [PM_ERR_STRING_INTERPOLATED_TERM] = "expected a closing delimiter for the interpolated string",
+ [PM_ERR_STRING_LITERAL_TERM] = "expected a closing delimiter for the string literal",
+ [PM_ERR_SYMBOL_INVALID] = "invalid symbol", // TODO expected symbol? prism.c ~9719
+ [PM_ERR_SYMBOL_TERM_DYNAMIC] = "expected a closing delimiter for the dynamic symbol",
+ [PM_ERR_SYMBOL_TERM_INTERPOLATED] = "expected a closing delimiter for the interpolated symbol",
+ [PM_ERR_TERNARY_COLON] = "expected a `:` after the true expression of a ternary operator",
+ [PM_ERR_TERNARY_EXPRESSION_FALSE] = "expected an expression after `:` in the ternary operator",
+ [PM_ERR_TERNARY_EXPRESSION_TRUE] = "expected an expression after `?` in the ternary operator",
+ [PM_ERR_UNDEF_ARGUMENT] = "invalid argument being passed to `undef`; expected a bare word, constant, or symbol argument",
+ [PM_ERR_UNARY_RECEIVER_BANG] = "expected a receiver for unary `!`",
+ [PM_ERR_UNARY_RECEIVER_MINUS] = "expected a receiver for unary `-`",
+ [PM_ERR_UNARY_RECEIVER_PLUS] = "expected a receiver for unary `+`",
+ [PM_ERR_UNARY_RECEIVER_TILDE] = "expected a receiver for unary `~`",
+ [PM_ERR_UNTIL_TERM] = "expected an `end` to close the `until` statement",
+ [PM_ERR_VOID_EXPRESSION] = "unexpected void value expression",
+ [PM_ERR_WHILE_TERM] = "expected an `end` to close the `while` statement",
+ [PM_ERR_WRITE_TARGET_READONLY] = "immutable variable as a write target",
+ [PM_ERR_WRITE_TARGET_UNEXPECTED] = "unexpected write target",
+ [PM_ERR_XSTRING_TERM] = "expected a closing delimiter for the `%x` or backtick string",
+ [PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_MINUS] = "ambiguous first argument; put parentheses or a space even after `-` operator",
+ [PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_PLUS] = "ambiguous first argument; put parentheses or a space even after `+` operator",
+ [PM_WARN_AMBIGUOUS_PREFIX_STAR] = "ambiguous `*` has been interpreted as an argument prefix",
+ [PM_WARN_AMBIGUOUS_SLASH] = "ambiguous `/`; wrap regexp in parentheses or add a space after `/` operator",
[PM_WARN_END_IN_METHOD] = "END in method; use at_exit",
};
diff --git a/test/prism/errors_test.rb b/test/prism/errors_test.rb
index 3289f67a71..bcc9629622 100644
--- a/test/prism/errors_test.rb
+++ b/test/prism/errors_test.rb
@@ -8,8 +8,8 @@ module Prism
def test_constant_path_with_invalid_token_after
assert_error_messages "A::$b", [
- "Expected a constant after the `::` operator",
- "Expected a newline or semicolon after the statement"
+ "expected a constant after the `::` operator",
+ "expected a newline or semicolon after the statement"
]
end
@@ -26,7 +26,7 @@ module Prism
)
assert_errors expected, "module Parent module end", [
- ["Expected a constant name after `module`", 20..20]
+ ["expected a constant name after `module`", 20..20]
]
end
@@ -42,7 +42,7 @@ module Prism
)
assert_errors expected, "for in 1..10\ni\nend", [
- ["Expected an index after `for`", 0..3]
+ ["expected an index after `for`", 0..3]
]
end
@@ -58,9 +58,9 @@ module Prism
)
assert_errors expected, "for end", [
- ["Expected an index after `for`", 0..3],
- ["Expected an `in` after the index in a `for` statement", 3..3],
- ["Expected a collection after the `in` in a `for` statement", 3..3]
+ ["expected an index after `for`", 0..3],
+ ["expected an `in` after the index in a `for` statement", 3..3],
+ ["expected a collection after the `in` in a `for` statement", 3..3]
]
end
@@ -73,7 +73,7 @@ module Prism
)
assert_errors expected, "BEGIN 1 }", [
- ["Expected a `{` after `BEGIN`", 5..5]
+ ["expected a `{` after `BEGIN`", 5..5]
]
end
@@ -98,37 +98,37 @@ module Prism
)
assert_errors expected, "BEGIN { 1 + }", [
- ["Expected an expression after the operator", 11..11]
+ ["expected an expression after the operator", 11..11]
]
end
def test_unterminated_embdoc
assert_errors expression("1"), "1\n=begin\n", [
- ["Could not find a terminator for the embedded document", 2..9]
+ ["could not find a terminator for the embedded document", 2..9]
]
end
def test_unterminated_i_list
assert_errors expression("%i["), "%i[", [
- ["Expected a closing delimiter for the `%i` list", 3..3]
+ ["expected a closing delimiter for the `%i` list", 3..3]
]
end
def test_unterminated_w_list
assert_errors expression("%w["), "%w[", [
- ["Expected a closing delimiter for the `%w` list", 3..3]
+ ["expected a closing delimiter for the `%w` list", 3..3]
]
end
def test_unterminated_W_list
assert_errors expression("%W["), "%W[", [
- ["Expected a closing delimiter for the `%W` list", 3..3]
+ ["expected a closing delimiter for the `%W` list", 3..3]
]
end
def test_unterminated_regular_expression
assert_errors expression("/hello"), "/hello", [
- ["Expected a closing delimiter for the regular expression", 1..1]
+ ["expected a closing delimiter for the regular expression", 1..1]
]
end
@@ -136,204 +136,204 @@ module Prism
source = "<<-END + /b\nEND\n"
assert_errors expression(source), source, [
- ["Expected a closing delimiter for the regular expression", 16..16]
+ ["expected a closing delimiter for the regular expression", 16..16]
]
end
def test_unterminated_xstring
assert_errors expression("`hello"), "`hello", [
- ["Expected a closing delimiter for the `%x` or backtick string", 1..1]
+ ["expected a closing delimiter for the `%x` or backtick string", 1..1]
]
end
def test_unterminated_string
assert_errors expression('"hello'), '"hello', [
- ["Expected a closing delimiter for the interpolated string", 1..1]
+ ["expected a closing delimiter for the interpolated string", 1..1]
]
end
def test_incomplete_instance_var_string
assert_errors expression('%@#@@#'), '%@#@@#', [
- ["Incomplete instance variable", 4..5],
- ["Expected a newline or semicolon after the statement", 4..4]
+ ["incomplete instance variable", 4..5],
+ ["expected a newline or semicolon after the statement", 4..4]
]
end
def test_unterminated_s_symbol
assert_errors expression("%s[abc"), "%s[abc", [
- ["Expected a closing delimiter for the dynamic symbol", 3..3]
+ ["expected a closing delimiter for the dynamic symbol", 3..3]
]
end
def test_unterminated_parenthesized_expression
assert_errors expression('(1 + 2'), '(1 + 2', [
- ["Expected a newline or semicolon after the statement", 6..6],
- ["Cannot parse the expression", 6..6],
- ["Expected a matching `)`", 6..6]
+ ["expected a newline or semicolon after the statement", 6..6],
+ ["cannot parse the expression", 6..6],
+ ["expected a matching `)`", 6..6]
]
end
def test_missing_terminator_in_parentheses
assert_error_messages "(0 0)", [
- "Expected a newline or semicolon after the statement"
+ "expected a newline or semicolon after the statement"
]
end
def test_unterminated_argument_expression
assert_errors expression('a %'), 'a %', [
- ["Invalid `%` token", 2..3],
- ["Expected an expression after the operator", 3..3],
+ ["invalid `%` token", 2..3],
+ ["expected an expression after the operator", 3..3],
]
end
def test_unterminated_interpolated_symbol
assert_error_messages ":\"#", [
- "Expected a closing delimiter for the interpolated symbol"
+ "expected a closing delimiter for the interpolated symbol"
]
end
def test_cr_without_lf_in_percent_expression
assert_errors expression("%\r"), "%\r", [
- ["Invalid `%` token", 0..2],
+ ["invalid `%` token", 0..2],
]
end
def test_1_2_3
assert_errors expression("(1, 2, 3)"), "(1, 2, 3)", [
- ["Expected a newline or semicolon after the statement", 2..2],
- ["Cannot parse the expression", 2..2],
- ["Expected a matching `)`", 2..2],
- ["Expected a newline or semicolon after the statement", 2..2],
- ["Cannot parse the expression", 2..2],
- ["Expected a newline or semicolon after the statement", 5..5],
- ["Cannot parse the expression", 5..5],
- ["Expected a newline or semicolon after the statement", 8..8],
- ["Cannot parse the expression", 8..8]
+ ["expected a newline or semicolon after the statement", 2..2],
+ ["cannot parse the expression", 2..2],
+ ["expected a matching `)`", 2..2],
+ ["expected a newline or semicolon after the statement", 2..2],
+ ["cannot parse the expression", 2..2],
+ ["expected a newline or semicolon after the statement", 5..5],
+ ["cannot parse the expression", 5..5],
+ ["expected a newline or semicolon after the statement", 8..8],
+ ["cannot parse the expression", 8..8]
]
end
def test_return_1_2_3
assert_error_messages "return(1, 2, 3)", [
- "Expected a newline or semicolon after the statement",
- "Cannot parse the expression",
- "Expected a matching `)`",
- "Expected a newline or semicolon after the statement",
- "Cannot parse the expression"
+ "expected a newline or semicolon after the statement",
+ "cannot parse the expression",
+ "expected a matching `)`",
+ "expected a newline or semicolon after the statement",
+ "cannot parse the expression"
]
end
def test_return_1
assert_errors expression("return 1,;"), "return 1,;", [
- ["Expected an argument", 9..9]
+ ["expected an argument", 9..9]
]
end
def test_next_1_2_3
assert_errors expression("next(1, 2, 3)"), "next(1, 2, 3)", [
- ["Expected a newline or semicolon after the statement", 6..6],
- ["Cannot parse the expression", 6..6],
- ["Expected a matching `)`", 6..6],
- ["Expected a newline or semicolon after the statement", 12..12],
- ["Cannot parse the expression", 12..12]
+ ["expected a newline or semicolon after the statement", 6..6],
+ ["cannot parse the expression", 6..6],
+ ["expected a matching `)`", 6..6],
+ ["expected a newline or semicolon after the statement", 12..12],
+ ["cannot parse the expression", 12..12]
]
end
def test_next_1
assert_errors expression("next 1,;"), "next 1,;", [
- ["Expected an argument", 7..7]
+ ["expected an argument", 7..7]
]
end
def test_break_1_2_3
assert_errors expression("break(1, 2, 3)"), "break(1, 2, 3)", [
- ["Expected a newline or semicolon after the statement", 7..7],
- ["Cannot parse the expression", 7..7],
- ["Expected a matching `)`", 7..7],
- ["Expected a newline or semicolon after the statement", 13..13],
- ["Cannot parse the expression", 13..13]
+ ["expected a newline or semicolon after the statement", 7..7],
+ ["cannot parse the expression", 7..7],
+ ["expected a matching `)`", 7..7],
+ ["expected a newline or semicolon after the statement", 13..13],
+ ["cannot parse the expression", 13..13]
]
end
def test_break_1
assert_errors expression("break 1,;"), "break 1,;", [
- ["Expected an argument", 8..8]
+ ["expected an argument", 8..8]
]
end
def test_argument_forwarding_when_parent_is_not_forwarding
assert_errors expression('def a(x, y, z); b(...); end'), 'def a(x, y, z); b(...); end', [
- ["Unexpected `...` when the parent method is not forwarding", 18..21]
+ ["unexpected `...` when the parent method is not forwarding", 18..21]
]
end
def test_argument_forwarding_only_effects_its_own_internals
assert_errors expression('def a(...); b(...); end; def c(x, y, z); b(...); end'),
'def a(...); b(...); end; def c(x, y, z); b(...); end', [
- ["Unexpected `...` when the parent method is not forwarding", 43..46]
+ ["unexpected `...` when the parent method is not forwarding", 43..46]
]
end
def test_top_level_constant_with_downcased_identifier
assert_error_messages "::foo", [
- "Expected a constant after the `::` operator",
- "Expected a newline or semicolon after the statement"
+ "expected a constant after the `::` operator",
+ "expected a newline or semicolon after the statement"
]
end
def test_top_level_constant_starting_with_downcased_identifier
assert_error_messages "::foo::A", [
- "Expected a constant after the `::` operator",
- "Expected a newline or semicolon after the statement"
+ "expected a constant after the `::` operator",
+ "expected a newline or semicolon after the statement"
]
end
def test_aliasing_global_variable_with_non_global_variable
assert_errors expression("alias $a b"), "alias $a b", [
- ["Invalid argument being passed to `alias`; expected a bare word, symbol, constant, or global variable", 9..10]
+ ["invalid argument being passed to `alias`; expected a bare word, symbol, constant, or global variable", 9..10]
]
end
def test_aliasing_non_global_variable_with_global_variable
assert_errors expression("alias a $b"), "alias a $b", [
- ["Invalid argument being passed to `alias`; expected a bare word, symbol, constant, or global variable", 8..10]
+ ["invalid argument being passed to `alias`; expected a bare word, symbol, constant, or global variable", 8..10]
]
end
def test_aliasing_global_variable_with_global_number_variable
assert_errors expression("alias $a $1"), "alias $a $1", [
- ["Invalid argument being passed to `alias`; expected a bare word, symbol, constant, or global variable", 9..11]
+ ["invalid argument being passed to `alias`; expected a bare word, symbol, constant, or global variable", 9..11]
]
end
def test_def_with_expression_receiver_and_no_identifier
assert_errors expression("def (a); end"), "def (a); end", [
- ["Expected a `.` or `::` after the receiver in a method definition", 7..7],
- ["Expected a method name", 7..7]
+ ["expected a `.` or `::` after the receiver in a method definition", 7..7],
+ ["expected a method name", 7..7]
]
end
def test_def_with_multiple_statements_receiver
assert_errors expression("def (\na\nb\n).c; end"), "def (\na\nb\n).c; end", [
- ["Expected a matching `)`", 7..7],
- ["Expected a `.` or `::` after the receiver in a method definition", 7..7],
- ["Expected a method name", 7..7],
- ["Cannot parse the expression", 10..10],
- ["Cannot parse the expression", 11..11]
+ ["expected a matching `)`", 7..7],
+ ["expected a `.` or `::` after the receiver in a method definition", 7..7],
+ ["expected a method name", 7..7],
+ ["cannot parse the expression", 10..10],
+ ["cannot parse the expression", 11..11]
]
end
def test_def_with_empty_expression_receiver
assert_errors expression("def ().a; end"), "def ().a; end", [
- ["Expected a receiver for the method definition", 5..5]
+ ["expected a receiver for the method definition", 5..5]
]
end
def test_block_beginning_with_brace_and_ending_with_end
assert_error_messages "x.each { x end", [
- "Expected a newline or semicolon after the statement",
- "Cannot parse the expression",
- "Cannot parse the expression",
- "Expected a block beginning with `{` to end with `}`"
+ "expected a newline or semicolon after the statement",
+ "cannot parse the expression",
+ "cannot parse the expression",
+ "expected a block beginning with `{` to end with `}`"
]
end
@@ -354,7 +354,7 @@ module Prism
)
assert_errors expected, "a(**kwargs, *args)", [
- ["Unexpected `*` splat argument after a `**` keyword splat argument", 12..17]
+ ["unexpected `*` splat argument after a `**` keyword splat argument", 12..17]
]
end
@@ -372,15 +372,15 @@ module Prism
)
assert_errors expected, "a(&block, foo)", [
- ["Unexpected argument after a block argument", 10..13]
+ ["unexpected argument after a block argument", 10..13]
]
end
def test_arguments_binding_power_for_and
assert_error_messages "foo(*bar and baz)", [
- "Expected a `)` to close the arguments",
- "Expected a newline or semicolon after the statement",
- "Cannot parse the expression"
+ "expected a `)` to close the arguments",
+ "expected a newline or semicolon after the statement",
+ "cannot parse the expression"
]
end
@@ -407,7 +407,7 @@ module Prism
)
assert_errors expected, "a(foo: bar, *args)", [
- ["Unexpected `*` splat argument after a `**` keyword splat argument", 12..17]
+ ["unexpected `*` splat argument after a `**` keyword splat argument", 12..17]
]
end
@@ -428,7 +428,7 @@ module Prism
)
assert_errors expected, "def foo;module A;end;end", [
- ["Unexpected module definition in a method body", 8..14]
+ ["unexpected module definition in a method body", 8..14]
]
end
@@ -466,7 +466,7 @@ module Prism
Location()
)
- assert_errors expected, <<~RUBY, [["Unexpected module definition in a method body", 21..27]]
+ assert_errors expected, <<~RUBY, [["unexpected module definition in a method body", 21..27]]
def foo
bar do
module Foo;end
@@ -503,7 +503,7 @@ module Prism
)
assert_errors expected, "def foo;class A;end;end", [
- ["Unexpected class definition in a method body", 8..13]
+ ["unexpected class definition in a method body", 8..13]
]
end
@@ -529,10 +529,10 @@ module Prism
)
assert_errors expected, "def foo(A, @a, $A, @@a);end", [
- ["Invalid formal argument; formal argument cannot be a constant", 8..9],
- ["Invalid formal argument; formal argument cannot be an instance variable", 11..13],
- ["Invalid formal argument; formal argument cannot be a global variable", 15..17],
- ["Invalid formal argument; formal argument cannot be a class variable", 19..22],
+ ["invalid formal argument; formal argument cannot be a constant", 8..9],
+ ["invalid formal argument; formal argument cannot be an instance variable", 11..13],
+ ["invalid formal argument; formal argument cannot be a global variable", 15..17],
+ ["invalid formal argument; formal argument cannot be a class variable", 19..22],
]
end
@@ -600,7 +600,7 @@ module Prism
)
assert_errors expected, "def foo(a,b,c,);end", [
- ["Unexpected `,` in parameters", 13..14]
+ ["unexpected `,` in parameters", 13..14]
]
end
@@ -619,7 +619,7 @@ module Prism
nil
)
assert_errors expected, "-> (a, b, ) {}", [
- ["Unexpected `,` in parameters", 8..9]
+ ["unexpected `,` in parameters", 8..9]
]
end
@@ -627,13 +627,13 @@ module Prism
expected = StringNode(0, Location(), Location(), nil, "\u0001\u0002")
assert_errors expected, '?\u{0001 0002}', [
- ["Invalid Unicode escape sequence; multiple codepoints are not allowed in a character literal", 9..12]
+ ["invalid Unicode escape sequence; multiple codepoints are not allowed in a character literal", 9..12]
]
end
def test_invalid_hex_escape
assert_errors expression('"\\xx"'), '"\\xx"', [
- ["Invalid hexadecimal escape sequence", 1..3],
+ ["invalid hexadecimal escape sequence", 1..3],
]
end
@@ -641,7 +641,7 @@ module Prism
expected = StringNode(0, Location(), Location(), Location(), "\u0001")
assert_errors expected, '"\u{0000001}"', [
- ["Invalid Unicode escape sequence; maximum length is 6 digits", 4..11],
+ ["invalid Unicode escape sequence; maximum length is 6 digits", 4..11],
]
end
@@ -649,13 +649,13 @@ module Prism
expected = StringNode(0, Location(), Location(), Location(), "\u0000z}")
assert_errors expected, '"\u{000z}"', [
- ["Invalid Unicode escape sequence", 7..7],
+ ["invalid Unicode escape sequence", 7..7],
]
end
def test_unterminated_unicode_brackets_should_be_a_syntax_error
assert_errors expression('?\\u{3'), '?\\u{3', [
- ["Invalid Unicode escape sequence; needs closing `}`", 1..5],
+ ["invalid Unicode escape sequence; needs closing `}`", 1..5],
]
end
@@ -683,7 +683,7 @@ module Prism
Location()
)
assert_errors expected, "def foo(&block, a)\nend", [
- ["Unexpected parameter order", 16..17]
+ ["unexpected parameter order", 16..17]
]
end
@@ -704,7 +704,7 @@ module Prism
)
assert_errors expected, "def foo(&, a)\nend", [
- ["Unexpected parameter order", 11..12]
+ ["unexpected parameter order", 11..12]
]
end
@@ -732,7 +732,7 @@ module Prism
Location()
)
assert_errors expected, "def foo(..., a)\nend", [
- ["Unexpected parameter order", 13..14]
+ ["unexpected parameter order", 13..14]
]
end
@@ -760,7 +760,7 @@ module Prism
Location()
)
assert_errors expected, "def foo(b:, a)\nend", [
- ["Unexpected parameter order", 12..13]
+ ["unexpected parameter order", 12..13]
]
end
@@ -789,7 +789,7 @@ module Prism
)
assert_errors expected, "def foo(**rest, b:)\nend", [
- ["Unexpected parameter order", 16..18]
+ ["unexpected parameter order", 16..18]
]
end
@@ -810,7 +810,7 @@ module Prism
)
assert_errors expected, "def foo(..., ...)\nend", [
- ["Unexpected parameter order", 13..16]
+ ["unexpected parameter order", 13..16]
]
end
@@ -839,8 +839,8 @@ module Prism
)
assert_errors expected, "def foo(**args, a, b:)\nend", [
- ["Unexpected parameter order", 16..17],
- ["Unexpected parameter order", 19..21]
+ ["unexpected parameter order", 16..17],
+ ["unexpected parameter order", 19..21]
]
end
@@ -869,8 +869,8 @@ module Prism
)
assert_errors expected, "def foo(**args, a, b:)\nend", [
- ["Unexpected parameter order", 16..17],
- ["Unexpected parameter order", 19..21]
+ ["unexpected parameter order", 16..17],
+ ["unexpected parameter order", 19..21]
]
end
@@ -899,8 +899,8 @@ module Prism
)
assert_errors expected, "def foo(**args, a, b:)\nend", [
- ["Unexpected parameter order", 16..17],
- ["Unexpected parameter order", 19..21]
+ ["unexpected parameter order", 16..17],
+ ["unexpected parameter order", 19..21]
]
end
@@ -932,7 +932,7 @@ module Prism
)
assert_errors expected, "def foo(a, b = 1, c, d = 2, e)\nend", [
- ["Unexpected parameter order", 23..24]
+ ["unexpected parameter order", 23..24]
]
end
@@ -946,7 +946,7 @@ module Prism
)
assert_errors expected, "case :a\nelse\nend", [
- ["Expected a `when` or `in` clause after `case`", 0..4]
+ ["expected a `when` or `in` clause after `case`", 0..4]
]
end
@@ -960,7 +960,7 @@ module Prism
)
assert_errors expected, "case :a\nend", [
- ["Expected a `when` or `in` clause after `case`", 0..4]
+ ["expected a `when` or `in` clause after `case`", 0..4]
]
end
@@ -981,7 +981,7 @@ module Prism
)
assert_errors expected, "def a=() = 42", [
- ["Invalid method name; a setter method cannot be defined in an endless method definition", 4..6]
+ ["invalid method name; a setter method cannot be defined in an endless method definition", 4..6]
]
end
@@ -996,7 +996,7 @@ module Prism
)
assert_errors expected, "->(...) {}", [
- ["Unexpected `...` when the parent method is not forwarding", 3..6]
+ ["unexpected `...` when the parent method is not forwarding", 3..6]
]
end
@@ -1020,7 +1020,7 @@ module Prism
)
assert_errors expected, "a {|...|}", [
- ["Unexpected `...` when the parent method is not forwarding", 4..7]
+ ["unexpected `...` when the parent method is not forwarding", 4..7]
]
end
@@ -1037,7 +1037,7 @@ module Prism
)
assert_errors expected, "class A; return; end", [
- ["Invalid `return` in a class or module body", 15..16]
+ ["invalid `return` in a class or module body", 15..16]
]
end
@@ -1052,7 +1052,7 @@ module Prism
)
assert_errors expected, "module A; return; end", [
- ["Invalid `return` in a class or module body", 16..17]
+ ["invalid `return` in a class or module body", 16..17]
]
end
@@ -1070,8 +1070,8 @@ module Prism
)
assert_errors expected, "begin\n$+ = nil\n$1466 = nil\nend", [
- ["Immutable variable as a write target", 6..8],
- ["Immutable variable as a write target", 15..20]
+ ["immutable variable as a write target", 6..8],
+ ["immutable variable as a write target", 15..20]
]
end
@@ -1095,7 +1095,7 @@ module Prism
)
assert_errors expected, "def foo(a,b,a);end", [
- ["Repeated parameter name", 12..13]
+ ["repeated parameter name", 12..13]
]
end
@@ -1115,7 +1115,7 @@ module Prism
)
assert_errors expected, "def foo(a,b,*a);end", [
- ["Repeated parameter name", 13..14]
+ ["repeated parameter name", 13..14]
]
expected = DefNode(
@@ -1134,7 +1134,7 @@ module Prism
)
assert_errors expected, "def foo(a,b,**a);end", [
- ["Repeated parameter name", 14..15]
+ ["repeated parameter name", 14..15]
]
expected = DefNode(
@@ -1153,7 +1153,7 @@ module Prism
)
assert_errors expected, "def foo(a,b,&a);end", [
- ["Repeated parameter name", 13..14]
+ ["repeated parameter name", 13..14]
]
expected = DefNode(
@@ -1171,7 +1171,7 @@ module Prism
Location()
)
- assert_errors expected, "def foo(a = 1,b,*c);end", [["Unexpected parameter `*`", 16..17]]
+ assert_errors expected, "def foo(a = 1,b,*c);end", [["unexpected parameter `*`", 16..17]]
end
def test_invalid_message_name
@@ -1182,33 +1182,33 @@ module Prism
def test_invalid_operator_write_fcall
source = "foo! += 1"
assert_errors expression(source), source, [
- ["Unexpected write target", 0..4]
+ ["unexpected write target", 0..4]
]
end
def test_invalid_operator_write_dot
source = "foo.+= 1"
assert_errors expression(source), source, [
- ["Unexpected write target", 5..6]
+ ["unexpected write target", 5..6]
]
end
def test_unterminated_global_variable
assert_errors expression("$"), "$", [
- ["Invalid global variable", 0..1]
+ ["invalid global variable", 0..1]
]
end
def test_invalid_global_variable_write
assert_errors expression("$',"), "$',", [
- ["Immutable variable as a write target", 0..2],
- ["Unexpected write target", 0..2]
+ ["immutable variable as a write target", 0..2],
+ ["unexpected write target", 0..2]
]
end
def test_invalid_multi_target
- error_messages = ["Unexpected write target"]
- immutable = "Immutable variable as a write target"
+ error_messages = ["unexpected write target"]
+ immutable = "immutable variable as a write target"
assert_error_messages "foo,", error_messages
assert_error_messages "foo = 1; foo,", error_messages
@@ -1235,51 +1235,51 @@ module Prism
def test_call_with_block_and_write
source = "foo {} &&= 1"
assert_errors expression(source), source, [
- ["Unexpected write target", 0..6],
- ["Unexpected operator after a call with a block", 7..10]
+ ["unexpected write target", 0..6],
+ ["unexpected operator after a call with a block", 7..10]
]
end
def test_call_with_block_or_write
source = "foo {} ||= 1"
assert_errors expression(source), source, [
- ["Unexpected write target", 0..6],
- ["Unexpected operator after a call with a block", 7..10]
+ ["unexpected write target", 0..6],
+ ["unexpected operator after a call with a block", 7..10]
]
end
def test_call_with_block_operator_write
source = "foo {} += 1"
assert_errors expression(source), source, [
- ["Unexpected write target", 0..6],
- ["Unexpected operator after a call with a block", 7..9]
+ ["unexpected write target", 0..6],
+ ["unexpected operator after a call with a block", 7..9]
]
end
def test_index_call_with_block_and_write
source = "foo[1] {} &&= 1"
assert_errors expression(source), source, [
- ["Unexpected write target", 0..9],
- ["Unexpected operator after a call with arguments", 10..13],
- ["Unexpected operator after a call with a block", 10..13]
+ ["unexpected write target", 0..9],
+ ["unexpected operator after a call with arguments", 10..13],
+ ["unexpected operator after a call with a block", 10..13]
]
end
def test_index_call_with_block_or_write
source = "foo[1] {} ||= 1"
assert_errors expression(source), source, [
- ["Unexpected write target", 0..9],
- ["Unexpected operator after a call with arguments", 10..13],
- ["Unexpected operator after a call with a block", 10..13]
+ ["unexpected write target", 0..9],
+ ["unexpected operator after a call with arguments", 10..13],
+ ["unexpected operator after a call with a block", 10..13]
]
end
def test_index_call_with_block_operator_write
source = "foo[1] {} += 1"
assert_errors expression(source), source, [
- ["Unexpected write target", 0..9],
- ["Unexpected operator after a call with arguments", 10..12],
- ["Unexpected operator after a call with a block", 10..12]
+ ["unexpected write target", 0..9],
+ ["unexpected operator after a call with arguments", 10..12],
+ ["unexpected operator after a call with a block", 10..12]
]
end
@@ -1304,13 +1304,13 @@ module Prism
def test_double_scope_numbered_parameters
source = "-> { _1 + -> { _2 } }"
- errors = [["Numbered parameter is already used in outer scope", 15..17]]
+ errors = [["numbered parameter is already used in outer scope", 15..17]]
assert_errors expression(source), source, errors, compare_ripper: false
end
def test_invalid_number_underscores
- error_messages = ["Invalid underscore placement in number"]
+ error_messages = ["invalid underscore placement in number"]
assert_error_messages "1__1", error_messages
assert_error_messages "0b1__1", error_messages
@@ -1328,7 +1328,7 @@ module Prism
end
def test_alnum_delimiters
- error_messages = ["Invalid `%` token"]
+ error_messages = ["invalid `%` token"]
assert_error_messages "%qXfooX", error_messages
assert_error_messages "%QXfooX", error_messages
@@ -1358,17 +1358,17 @@ module Prism
def test_conditional_predicate_closed
source = "if 0 0; elsif 0 0; end\nunless 0 0; end"
assert_errors expression(source), source, [
- ["Expected `then` or `;` or '\n" + "'", 5..6],
- ["Expected `then` or `;` or '\n" + "'", 16..17],
- ["Expected `then` or `;` or '\n" + "'", 32..33],
+ ["expected `then` or `;` or '\n" + "'", 5..6],
+ ["expected `then` or `;` or '\n" + "'", 16..17],
+ ["expected `then` or `;` or '\n" + "'", 32..33],
]
end
def test_parameter_name_ending_with_bang_or_question_mark
source = "def foo(x!,y?); end"
errors = [
- ["Unexpected name for a parameter", 8..10],
- ["Unexpected name for a parameter", 11..13]
+ ["unexpected name for a parameter", 8..10],
+ ["unexpected name for a parameter", 11..13]
]
assert_errors expression(source), source, errors, compare_ripper: false
end
@@ -1376,46 +1376,46 @@ module Prism
def test_class_name
source = "class 0.X end"
assert_errors expression(source), source, [
- ["Expected a constant name after `class`", 6..9],
+ ["expected a constant name after `class`", 6..9],
]
end
def test_loop_conditional_is_closed
source = "while 0 0; foo; end; until 0 0; foo; end"
assert_errors expression(source), source, [
- ["Expected a predicate expression for the `while` statement", 7..7],
- ["Expected a predicate expression for the `until` statement", 28..28],
+ ["expected a predicate expression for the `while` statement", 7..7],
+ ["expected a predicate expression for the `until` statement", 28..28],
]
end
def test_forwarding_arg_after_keyword_rest
source = "def f(**,...);end"
assert_errors expression(source), source, [
- ["Unexpected `...` in parameters", 9..12],
+ ["unexpected `...` in parameters", 9..12],
]
end
def test_semicolon_after_inheritance_operator
source = "class Foo < Bar end"
assert_errors expression(source), source, [
- ["Unexpected `end`, expecting ';' or '\n'", 15..15],
+ ["unexpected `end`, expecting ';' or '\n'", 15..15],
]
end
def test_shadow_args_in_lambda
source = "->a;b{}"
assert_errors expression(source), source, [
- ["Expected a `do` keyword or a `{` to open the lambda block", 3..3],
- ["Expected a newline or semicolon after the statement", 7..7],
- ["Cannot parse the expression", 7..7],
- ["Expected a lambda block beginning with `do` to end with `end`", 7..7],
+ ["expected a `do` keyword or a `{` to open the lambda block", 3..3],
+ ["expected a newline or semicolon after the statement", 7..7],
+ ["cannot parse the expression", 7..7],
+ ["expected a lambda block beginning with `do` to end with `end`", 7..7],
]
end
def test_shadow_args_in_block
source = "tap{|a;a|}"
assert_errors expression(source), source, [
- ["Repeated parameter name", 7..8],
+ ["repeated parameter name", 7..8],
]
end
@@ -1424,7 +1424,7 @@ module Prism
# In Ruby 3.0.x, `Ripper.sexp_raw` does not return `nil` for this case.
compare_ripper = RUBY_ENGINE == "ruby" && (RUBY_VERSION.split('.').map { |x| x.to_i } <=> [3, 1]) >= 1
assert_errors expression(source), source, [
- ["Repeated parameter name", 14..15],
+ ["repeated parameter name", 14..15],
], compare_ripper: compare_ripper
end
@@ -1450,23 +1450,23 @@ module Prism
def test_symbol_in_keyword_parameter
source = "def foo(x:'y':); end"
assert_errors expression(source), source, [
- ["Expected a closing delimiter for the string literal", 14..14],
+ ["expected a closing delimiter for the string literal", 14..14],
]
end
def test_symbol_in_hash
source = "{x:'y':}"
assert_errors expression(source), source, [
- ["Expected a closing delimiter for the string literal", 7..7],
+ ["expected a closing delimiter for the string literal", 7..7],
]
end
def test_while_endless_method
source = "while def f = g do end"
assert_errors expression(source), source, [
- ['Expected a predicate expression for the `while` statement', 22..22],
- ['Cannot parse the expression', 22..22],
- ['Expected an `end` to close the `while` statement', 22..22]
+ ['expected a predicate expression for the `while` statement', 22..22],
+ ['cannot parse the expression', 22..22],
+ ['expected an `end` to close the `while` statement', 22..22]
]
end
@@ -1475,8 +1475,8 @@ module Prism
a in b + c
a => b + c
RUBY
- message1 = 'Expected a newline or semicolon after the statement'
- message2 = 'Cannot parse the expression'
+ message1 = 'expected a newline or semicolon after the statement'
+ message2 = 'cannot parse the expression'
assert_errors expression(source), source, [
[message1, 6..6],
[message2, 6..6],
@@ -1487,7 +1487,7 @@ module Prism
def test_rational_number_with_exponential_portion
source = '1e1r; 1e1ri'
- message = 'Expected a newline or semicolon after the statement'
+ message = 'expected a newline or semicolon after the statement'
assert_errors expression(source), source, [
[message, 3..3],
[message, 9..9]
@@ -1507,7 +1507,7 @@ module Prism
1 => ^(if 1; (return) else (return) end)
1 => ^(unless 1; (return) else (return) end)
RUBY
- message = 'Unexpected void value expression'
+ message = 'unexpected void value expression'
assert_errors expression(source), source, [
[message, 7..13],
[message, 35..40],
@@ -1540,7 +1540,7 @@ module Prism
for x in (return)
end
RUBY
- message = 'Unexpected void value expression'
+ message = 'unexpected void value expression'
assert_errors expression(source), source, [
[message, 4..10],
[message, 24..30],
@@ -1562,7 +1562,7 @@ module Prism
def x(a: return)
end
RUBY
- message = 'Unexpected void value expression'
+ message = 'unexpected void value expression'
assert_errors expression(source), source, [
[message, 5..11],
[message, 29..35],
@@ -1577,7 +1577,7 @@ module Prism
a, b = return, 1
a, b = 1, *return
RUBY
- message = 'Unexpected void value expression'
+ message = 'unexpected void value expression'
assert_errors expression(source), source, [
[message, 4..10],
[message, 18..24],
@@ -1595,7 +1595,7 @@ module Prism
(return) => a
(return) in a
RUBY
- message = 'Unexpected void value expression'
+ message = 'unexpected void value expression'
assert_errors expression(source), source, [
[message, 6..12],
[message, 24..30],
@@ -1618,7 +1618,7 @@ module Prism
((return)..)
((return)...)
RUBY
- message = 'Unexpected void value expression'
+ message = 'unexpected void value expression'
assert_errors expression(source), source, [
[message, 1..7],
[message, 18..24],
@@ -1639,7 +1639,7 @@ module Prism
{ a: return }
{ **return }
RUBY
- message = 'Unexpected void value expression'
+ message = 'unexpected void value expression'
assert_errors expression(source), source, [
[message, 2..8],
[message, 23..29],
@@ -1656,7 +1656,7 @@ module Prism
(return)[1] = 2
(return)::foo
RUBY
- message = 'Unexpected void value expression'
+ message = 'unexpected void value expression'
assert_errors expression(source), source, [
[message, 1..7],
[message, 14..20],
@@ -1671,7 +1671,7 @@ module Prism
(return)::A
class (return)::A; end
RUBY
- message = 'Unexpected void value expression'
+ message = 'unexpected void value expression'
assert_errors expression(source), source, [
[message, 1..7],
[message, 19..25],
@@ -1689,7 +1689,7 @@ module Prism
foo(:a => return)
foo(a: return)
RUBY
- message = 'Unexpected void value expression'
+ message = 'unexpected void value expression'
assert_errors expression(source), source, [
[message, 4..10],
[message, 19..25],
@@ -1707,7 +1707,7 @@ module Prism
+(return)
not return
RUBY
- message = 'Unexpected void value expression'
+ message = 'unexpected void value expression'
assert_errors expression(source), source, [
[message, 2..8],
[message, 14..20],
@@ -1723,7 +1723,7 @@ module Prism
1 or (return)
(return) or 1
RUBY
- message = 'Unexpected void value expression'
+ message = 'unexpected void value expression'
assert_errors expression(source), source, [
[message, 5..11],
[message, 14..20],
@@ -1734,29 +1734,29 @@ module Prism
def test_trailing_comma_in_calls
assert_errors expression("foo 1,"), "foo 1,", [
- ["Expected an argument", 5..6]
+ ["expected an argument", 5..6]
]
end
def test_argument_after_ellipsis
source = 'def foo(...); foo(..., 1); end'
assert_errors expression(source), source, [
- ['Unexpected argument after `...`', 23..24]
+ ['unexpected argument after `...`', 23..24]
]
end
def test_ellipsis_in_no_paren_call
source = 'def foo(...); foo 1, ...; end'
assert_errors expression(source), source, [
- ['Unexpected `...` in an non-parenthesized call', 21..24]
+ ['unexpected `...` in an non-parenthesized call', 21..24]
]
end
def test_non_assoc_range
source = '1....2'
assert_errors expression(source), source, [
- ['Expected a newline or semicolon after the statement', 4..4],
- ['Cannot parse the expression', 4..4],
+ ['expected a newline or semicolon after the statement', 4..4],
+ ['cannot parse the expression', 4..4],
]
end
@@ -1777,8 +1777,8 @@ module Prism
undef x + 1
undef x.z
RUBY
- message1 = 'Expected a newline or semicolon after the statement'
- message2 = 'Cannot parse the expression'
+ message1 = 'expected a newline or semicolon after the statement'
+ message2 = 'cannot parse the expression'
assert_errors expression(source), source, [
[message1, 9..9],
[message2, 9..9],
@@ -1807,10 +1807,10 @@ module Prism
foo(undef x)
RUBY
assert_errors expression(source), source, [
- ['Unexpected an `alias` at a non-statement position', 4..9],
- ['Unexpected a `BEGIN` at a non-statement position', 19..24],
- ['Unexpected an `END` at a non-statement position', 38..41],
- ['Unexpected an `undef` at a non-statement position', 55..60],
+ ['unexpected an `alias` at a non-statement position', 4..9],
+ ['unexpected a `BEGIN` at a non-statement position', 19..24],
+ ['unexpected an `END` at a non-statement position', 38..41],
+ ['unexpected an `undef` at a non-statement position', 55..60],
]
end
@@ -1819,8 +1819,8 @@ module Prism
..1..
...1..
RUBY
- message1 = 'Expected a newline or semicolon after the statement'
- message2 = 'Cannot parse the expression'
+ message1 = 'expected a newline or semicolon after the statement'
+ message2 = 'cannot parse the expression'
assert_errors expression(source), source, [
[message1, 3..3],
[message2, 3..3],