Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ext/liquid_c/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "usage.h"

static VALUE empty_string;
static VALUE frozen_empty_array;
static ID id_to_i, idEvaluate;

void init_parser(parser_t *p, const char *str, const char *end)
Expand Down Expand Up @@ -178,7 +179,7 @@ static VALUE try_parse_literal(parser_t *p)
break;
case 'e':
if (memcmp(str, "empty", size) == 0)
result = empty_string;
result = frozen_empty_array;
break;
}
break;
Expand Down Expand Up @@ -272,5 +273,9 @@ void liquid_define_parser(void)

empty_string = rb_utf8_str_new_literal("");
rb_global_variable(&empty_string);

frozen_empty_array = rb_ary_new();
rb_ary_freeze(frozen_empty_array);
rb_global_variable(&frozen_empty_array);
}

6 changes: 4 additions & 2 deletions test/unit/expression_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ def test_constant_literals
assert_nil(Liquid::C::Expression.strict_parse('null'))

empty = Liquid::C::Expression.strict_parse('empty')
assert_equal('', empty)
assert_same(empty, Liquid::C::Expression.strict_parse('blank'))
assert_equal([], empty)

blank = Liquid::C::Expression.strict_parse('blank')
assert_equal('', blank)
end

def test_push_literals
Expand Down