Skip to content

Commit

Permalink
Always pass a mutable keyword arguments hash to filters (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanahsmith authored Oct 14, 2020
1 parent 29ba5ad commit aa0b3bf
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions ext/liquid_c/variable.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ static VALUE try_variable_strict_parse(VALUE uncast_args)
VALUE filter_name = token_to_rsym(filter_name_token);

size_t arg_count = 0;
bool const_keyword_args = true;
VALUE keyword_args = Qnil;

if (parser_consume(&p, TOKEN_COLON).type) {
Expand All @@ -59,8 +58,6 @@ static VALUE try_variable_strict_parse(VALUE uncast_args)
VALUE key = token_to_rstr(parser_consume_any(&p));
parser_consume_any(&p);

if (const_keyword_args && !will_parse_constant_expression_next(&p))
const_keyword_args = false;
if (keyword_args == Qnil)
keyword_args = rb_hash_new();
rb_hash_aset(keyword_args, key, parse_expression(&p));
Expand All @@ -76,12 +73,8 @@ static VALUE try_variable_strict_parse(VALUE uncast_args)
if (RHASH_SIZE(keyword_args) > 255) {
rb_enc_raise(utf8_encoding, cLiquidSyntaxError, "Too many filter keyword arguments");
}
if (const_keyword_args) {
vm_assembler_add_push_const(code, keyword_args);
} else {
rb_hash_foreach(keyword_args, compile_each_keyword_arg, (VALUE)code);
vm_assembler_add_hash_new(code, RHASH_SIZE(keyword_args));
}
rb_hash_foreach(keyword_args, compile_each_keyword_arg, (VALUE)code);
vm_assembler_add_hash_new(code, RHASH_SIZE(keyword_args));
}
if (arg_count > 254) {
rb_enc_raise(utf8_encoding, cLiquidSyntaxError, "Too many filter arguments");
Expand Down

0 comments on commit aa0b3bf

Please sign in to comment.