aboutsummaryrefslogtreecommitdiffstats
path: root/prism/parser.h
diff options
context:
space:
mode:
authorJemma Issroff <jemmaissroff@gmail.com>2023-11-28 15:42:33 -0500
committergit <svn-admin@ruby-lang.org>2023-11-28 21:08:46 +0000
commit04cbcd37b1c18c4db4b9df8d80abb4efec11755c (patch)
treecda45c96254e9720ac53101b74a962f4dace7c8a /prism/parser.h
parent6310522a9a33c19e963e56a8f87388d802525937 (diff)
downloadruby-04cbcd37b1c18c4db4b9df8d80abb4efec11755c.tar.gz
[ruby/prism] Add numbered_parameters field to BlockNode and LambdaNode
We are aware at parse time how many numbered parameters we have on a BlockNode or LambdaNode, but prior to this commit, did not store that information anywhere in its own right. The numbered parameters were stored as locals, but this does not distinguish them from other locals that have been set, for example in `a { b = 1; _1 }` there is nothing on the AST that distinguishes b from _1. Consumers such as the compiler need to know information about how many numbered parameters exist to set up their own tables around parameters. Since we have this information at parse time, we should compute it here, instead of deferring the work later on. https://github.com/ruby/prism/commit/bf4a1e124d
Diffstat (limited to 'prism/parser.h')
-rw-r--r--prism/parser.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/prism/parser.h b/prism/parser.h
index 8c98892ee9..fec1036229 100644
--- a/prism/parser.h
+++ b/prism/parser.h
@@ -468,11 +468,12 @@ typedef struct pm_scope {
bool explicit_params;
/**
- * A boolean indicating whether or not this scope has numbered parameters.
+ * An integer indicating the number of numbered parameters on this scope.
* This is necessary to determine if child blocks are allowed to use
- * numbered parameters.
+ * numbered parameters, and to pass information to consumers of the AST
+ * about how many numbered parameters exist.
*/
- bool numbered_params;
+ uint32_t numbered_parameters;
/**
* A transparent scope is a scope that cannot have locals set on itself.