@@ -1409,7 +1409,7 @@ pm_conditional_predicate_warn_write_literal_p(const pm_node_t *node) {
1409
1409
static inline void
1410
1410
pm_conditional_predicate_warn_write_literal(pm_parser_t *parser, const pm_node_t *node) {
1411
1411
if (pm_conditional_predicate_warn_write_literal_p(node)) {
1412
- pm_parser_warn_node(parser, node, parser->version = = PM_OPTIONS_VERSION_CRUBY_3_3 ? PM_WARN_EQUAL_IN_CONDITIONAL_3_3 : PM_WARN_EQUAL_IN_CONDITIONAL);
1412
+ pm_parser_warn_node(parser, node, parser->version < = PM_OPTIONS_VERSION_CRUBY_3_3 ? PM_WARN_EQUAL_IN_CONDITIONAL_3_3 : PM_WARN_EQUAL_IN_CONDITIONAL);
1413
1413
}
1414
1414
}
1415
1415
@@ -2976,7 +2976,7 @@ pm_call_and_write_node_create(pm_parser_t *parser, pm_call_node_t *target, const
2976
2976
*/
2977
2977
static void
2978
2978
pm_index_arguments_check(pm_parser_t *parser, const pm_arguments_node_t *arguments, const pm_node_t *block) {
2979
- if (parser->version != PM_OPTIONS_VERSION_CRUBY_3_3 ) {
2979
+ if (parser->version >= PM_OPTIONS_VERSION_CRUBY_3_4 ) {
2980
2980
if (arguments != NULL && PM_NODE_FLAG_P(arguments, PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORDS)) {
2981
2981
pm_node_t *node;
2982
2982
PM_NODE_LIST_FOREACH(&arguments->arguments, index, node) {
@@ -9113,7 +9113,7 @@ lex_global_variable(pm_parser_t *parser) {
9113
9113
} while ((width = char_is_identifier(parser, parser->current.end, parser->end - parser->current.end)) > 0);
9114
9114
9115
9115
// $0 isn't allowed to be followed by anything.
9116
- pm_diagnostic_id_t diag_id = parser->version = = PM_OPTIONS_VERSION_CRUBY_3_3 ? PM_ERR_INVALID_VARIABLE_GLOBAL_3_3 : PM_ERR_INVALID_VARIABLE_GLOBAL;
9116
+ pm_diagnostic_id_t diag_id = parser->version < = PM_OPTIONS_VERSION_CRUBY_3_3 ? PM_ERR_INVALID_VARIABLE_GLOBAL_3_3 : PM_ERR_INVALID_VARIABLE_GLOBAL;
9117
9117
PM_PARSER_ERR_TOKEN_FORMAT_CONTENT(parser, parser->current, diag_id);
9118
9118
}
9119
9119
@@ -9150,7 +9150,7 @@ lex_global_variable(pm_parser_t *parser) {
9150
9150
} else {
9151
9151
// If we get here, then we have a $ followed by something that
9152
9152
// isn't recognized as a global variable.
9153
- pm_diagnostic_id_t diag_id = parser->version = = PM_OPTIONS_VERSION_CRUBY_3_3 ? PM_ERR_INVALID_VARIABLE_GLOBAL_3_3 : PM_ERR_INVALID_VARIABLE_GLOBAL;
9153
+ pm_diagnostic_id_t diag_id = parser->version < = PM_OPTIONS_VERSION_CRUBY_3_3 ? PM_ERR_INVALID_VARIABLE_GLOBAL_3_3 : PM_ERR_INVALID_VARIABLE_GLOBAL;
9154
9154
const uint8_t *end = parser->current.end + parser->encoding->char_width(parser->current.end, parser->end - parser->current.end);
9155
9155
PM_PARSER_ERR_FORMAT(parser, parser->current.start, end, diag_id, (int) (end - parser->current.start), (const char *) parser->current.start);
9156
9156
}
@@ -10177,7 +10177,7 @@ lex_at_variable(pm_parser_t *parser) {
10177
10177
}
10178
10178
} else if (parser->current.end < end && pm_char_is_decimal_digit(*parser->current.end)) {
10179
10179
pm_diagnostic_id_t diag_id = (type == PM_TOKEN_CLASS_VARIABLE) ? PM_ERR_INCOMPLETE_VARIABLE_CLASS : PM_ERR_INCOMPLETE_VARIABLE_INSTANCE;
10180
- if (parser->version = = PM_OPTIONS_VERSION_CRUBY_3_3) {
10180
+ if (parser->version < = PM_OPTIONS_VERSION_CRUBY_3_3) {
10181
10181
diag_id = (type == PM_TOKEN_CLASS_VARIABLE) ? PM_ERR_INCOMPLETE_VARIABLE_CLASS_3_3 : PM_ERR_INCOMPLETE_VARIABLE_INSTANCE_3_3;
10182
10182
}
10183
10183
@@ -14667,7 +14667,7 @@ parse_parameters(
14667
14667
parser_lex(parser);
14668
14668
14669
14669
pm_constant_id_t name_id = pm_parser_constant_id_token(parser, &name);
14670
- uint32_t reads = parser->version = = PM_OPTIONS_VERSION_CRUBY_3_3 ? pm_locals_reads(&parser->current_scope->locals, name_id) : 0;
14670
+ uint32_t reads = parser->version < = PM_OPTIONS_VERSION_CRUBY_3_3 ? pm_locals_reads(&parser->current_scope->locals, name_id) : 0;
14671
14671
14672
14672
if (accepts_blocks_in_defaults) pm_accepts_block_stack_push(parser, true);
14673
14673
pm_node_t *value = parse_value_expression(parser, binding_power, false, false, PM_ERR_PARAMETER_NO_DEFAULT, (uint16_t) (depth + 1));
@@ -14683,7 +14683,7 @@ parse_parameters(
14683
14683
// If the value of the parameter increased the number of
14684
14684
// reads of that parameter, then we need to warn that we
14685
14685
// have a circular definition.
14686
- if ((parser->version = = PM_OPTIONS_VERSION_CRUBY_3_3) && (pm_locals_reads(&parser->current_scope->locals, name_id) != reads)) {
14686
+ if ((parser->version < = PM_OPTIONS_VERSION_CRUBY_3_3) && (pm_locals_reads(&parser->current_scope->locals, name_id) != reads)) {
14687
14687
PM_PARSER_ERR_TOKEN_FORMAT_CONTENT(parser, name, PM_ERR_PARAMETER_CIRCULAR);
14688
14688
}
14689
14689
@@ -14768,13 +14768,13 @@ parse_parameters(
14768
14768
14769
14769
if (token_begins_expression_p(parser->current.type)) {
14770
14770
pm_constant_id_t name_id = pm_parser_constant_id_token(parser, &local);
14771
- uint32_t reads = parser->version = = PM_OPTIONS_VERSION_CRUBY_3_3 ? pm_locals_reads(&parser->current_scope->locals, name_id) : 0;
14771
+ uint32_t reads = parser->version < = PM_OPTIONS_VERSION_CRUBY_3_3 ? pm_locals_reads(&parser->current_scope->locals, name_id) : 0;
14772
14772
14773
14773
if (accepts_blocks_in_defaults) pm_accepts_block_stack_push(parser, true);
14774
14774
pm_node_t *value = parse_value_expression(parser, binding_power, false, false, PM_ERR_PARAMETER_NO_DEFAULT_KW, (uint16_t) (depth + 1));
14775
14775
if (accepts_blocks_in_defaults) pm_accepts_block_stack_pop(parser);
14776
14776
14777
- if (parser->version = = PM_OPTIONS_VERSION_CRUBY_3_3 && (pm_locals_reads(&parser->current_scope->locals, name_id) != reads)) {
14777
+ if (parser->version < = PM_OPTIONS_VERSION_CRUBY_3_3 && (pm_locals_reads(&parser->current_scope->locals, name_id) != reads)) {
14778
14778
PM_PARSER_ERR_TOKEN_FORMAT_CONTENT(parser, local, PM_ERR_PARAMETER_CIRCULAR);
14779
14779
}
14780
14780
@@ -16478,7 +16478,7 @@ parse_variable(pm_parser_t *parser) {
16478
16478
pm_node_list_append(¤t_scope->implicit_parameters, node);
16479
16479
16480
16480
return node;
16481
- } else if ((parser->version != PM_OPTIONS_VERSION_CRUBY_3_3 ) && pm_token_is_it(parser->previous.start, parser->previous.end)) {
16481
+ } else if ((parser->version >= PM_OPTIONS_VERSION_CRUBY_3_4 ) && pm_token_is_it(parser->previous.start, parser->previous.end)) {
16482
16482
pm_node_t *node = (pm_node_t *) pm_it_local_variable_read_node_create(parser, &parser->previous);
16483
16483
pm_node_list_append(¤t_scope->implicit_parameters, node);
16484
16484
@@ -22641,6 +22641,12 @@ pm_parser_init(pm_parser_t *parser, const uint8_t *source, size_t size, const pm
22641
22641
}
22642
22642
}
22643
22643
22644
+ // Now that we have established the user-provided options, check if
22645
+ // a version was given and parse as the latest version otherwise.
22646
+ if (parser->version == PM_OPTIONS_VERSION_UNSET) {
22647
+ parser->version = PM_OPTIONS_VERSION_LATEST;
22648
+ }
22649
+
22644
22650
pm_accepts_block_stack_push(parser, true);
22645
22651
22646
22652
// Skip past the UTF-8 BOM if it exists.
0 commit comments