summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--prism_compile.c13
-rw-r--r--test/ruby/test_compile_prism.rb3
2 files changed, 16 insertions, 0 deletions
diff --git a/prism_compile.c b/prism_compile.c
index b4c5fc89df..9f736ebdc4 100644
--- a/prism_compile.c
+++ b/prism_compile.c
@@ -1512,6 +1512,19 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
}
return;
}
+ case PM_IMPLICIT_NODE: {
+ // Implicit nodes mark places in the syntax tree where explicit syntax
+ // was omitted, but implied. For example,
+ //
+ // { foo: }
+ //
+ // In this case a method call/local variable read is implied by virtue
+ // of the missing value. To compile these nodes, we simply compile the
+ // value that is implied, which is helpfully supplied by the parser.
+ pm_implicit_node_t *cast = (pm_implicit_node_t *)node;
+ PM_COMPILE(cast->value);
+ return;
+ }
case PM_INSTANCE_VARIABLE_AND_WRITE_NODE: {
pm_instance_variable_and_write_node_t *instance_variable_and_write_node = (pm_instance_variable_and_write_node_t*) node;
diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb
index 11d59a4373..6dc4f70c49 100644
--- a/test/ruby/test_compile_prism.rb
+++ b/test/ruby/test_compile_prism.rb
@@ -312,6 +312,9 @@ module Prism
test_prism_eval("{ a: :a }")
test_prism_eval("{ a: :a, b: :b }")
test_prism_eval("a = 1; { a: a }")
+ test_prism_eval("a = 1; { a: }")
+ test_prism_eval("{ to_s: }")
+ test_prism_eval("{ Prism: }")
end
############################################################################