diff --git a/libpub/parse.yy b/libpub/parse.yy index 9798905d..517a4b49 100644 --- a/libpub/parse.yy +++ b/libpub/parse.yy @@ -720,7 +720,11 @@ p3_bindings: p3_binding p3_binding: p3_bind_key p3_bind_value_opt { - $$ = pub3::binding_t ($1, $2); + auto v = $2; + if (!v) { + v = pub3::expr_null_t::alloc(); + } + $$ = pub3::binding_t ($1, v); } ; diff --git a/test/pub/Makefile.am b/test/pub/Makefile.am index 6834bdb3..a5b76539 100644 --- a/test/pub/Makefile.am +++ b/test/pub/Makefile.am @@ -1,6 +1,7 @@ PACKAGE_STRING=pub TESTS = \ dict_equal.pub \ + empty_key.pub \ scoping_for.pub \ scoping_globals-locals.pub \ scoping_order_of_decl.pub \ diff --git a/test/pub/empty_key.expected b/test/pub/empty_key.expected new file mode 100644 index 00000000..6d255f55 --- /dev/null +++ b/test/pub/empty_key.expected @@ -0,0 +1 @@ +["x", "y"] diff --git a/test/pub/empty_key.pub b/test/pub/empty_key.pub new file mode 100644 index 00000000..09a7ff47 --- /dev/null +++ b/test/pub/empty_key.pub @@ -0,0 +1,5 @@ +{% +x = 5; +v = {x:x, y} +print(sort(keys(v))); +%}