Reverse-sync &nil block handling#3926
Conversation
ruby/ruby#11065 https://bugs.ruby-lang.org/issues/19979 Co-authored-by: Ufuk Kayserilioglu <ufuk.kayserilioglu@shopify.com>
58aa74a to
d2d44d1
Compare
d2d44d1 to
8aad248
Compare
|
Hm, I wanted to build on top of this but tests don't actually succeed locally anymore. I get some unrelated failures first and eventually it segfaults on I played around with it a bit and seems it's caused by changing the type of Segfault
This is enough to make it crash (applied on top of 27c24fd) diff --git a/config.yml b/config.yml
index f6e99c66b..0736f5a0b 100644
--- a/config.yml
+++ b/config.yml
@@ -3920,6 +3920,18 @@ nodes:
nil
^^^
+ - name: NoBlockParameterNode
+ fields:
+ - name: operator_loc
+ type: location
+ - name: keyword_loc
+ type: location
+ comment: |
+ Represents the use of `&nil` inside method arguments.
+
+ def a(&nil)
+ ^^^^
+ end
- name: NoKeywordsParameterNode
fields:
- name: operator_loc
@@ -4066,7 +4078,9 @@ nodes:
- NoKeywordsParameterNode
- name: block
type: node?
- kind: BlockParameterNode
+ kind:
+ - BlockParameterNode
+ - NoBlockParameterNode
comment: |
Represents the list of parameters on a method, block, or lambda definition.
diff --git a/src/prism.c b/src/prism.c
index ca0f2a55a..0327d32fb 100644
--- a/src/prism.c
+++ b/src/prism.c
@@ -5787,9 +5787,9 @@ pm_parameters_node_keyword_rest_set(pm_parameters_node_t *params, pm_node_t *par
* Set the block parameter on a ParametersNode node.
*/
static void
-pm_parameters_node_block_set(pm_parameters_node_t *params, pm_block_parameter_node_t *param) {
+pm_parameters_node_block_set(pm_parameters_node_t *params, pm_node_t *param) {
assert(params->block == NULL);
- pm_parameters_node_location_set(params, UP(param));
+ pm_parameters_node_location_set(params, param);
params->block = param;
}
@@ -13945,7 +13945,7 @@ parse_parameters(
pm_node_flag_set_repeated_parameter(UP(param));
}
if (params->block == NULL) {
- pm_parameters_node_block_set(params, param);
+ pm_parameters_node_block_set(params, UP(param));
} else {
pm_parser_err_node(parser, UP(param), PM_ERR_PARAMETER_BLOCK_MULTI);
pm_parameters_node_posts_append(params, UP(param));cc @paracycle, @kddnewton. This is out of my comfort-zone. If I had to guess, then I would point my finger here Lines 257 to 286 in 7c16f77 |
|
@Earlopain can't reproduce locally. Any chance |
|
Huh, yeah. That does it. I tried on two machines but had it happen on both. 🤷 |
|
That probably means there's a dependency missing somewhere, where it doesn't know to rebuild something when |
ruby/ruby#11065
https://bugs.ruby-lang.org/issues/19979