-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document some nodes related to pattern matching #2914
base: main
Are you sure you want to change the base?
Conversation
ca609d2
to
94a709c
Compare
- name: pattern
type: node
comment: |
Represents the right-hand side of the operator. The type of the node depends on the expression.
Anything that looks like a local variable name (including `_`) will result in a `LocalVariableTargetNode`.
foo => a # This is equivalent to writing `a = foo`
^
Using an explicit `Array` or combining expressions with `,` will result in a `ArrayPatternNode`. This can be preceded by a constant.
foo => [a]
^^^
foo => a, b
^^^^
foo => Bar[a, b]
^^^^^^^^^
If the array pattern contains at least two wildcard matches, a `FindPatternNode` is created instead.
foo => *, *a
^^^^^
Using an explicit `Hash` or a constant with square brackets and hash keys in the square brackets will result in a `HashPatternNode`.
foo => { a: 1, b: }
foo => Bar[a: 1, b:]
foo => Bar[**]
Anything else will result in the regular node for that expression, for example a `ConstantReadNode`.
foo => CONST But this information applies to other locations as well. It is recursively applied to all possible fields (e.g. something that looks like a variable name inside an |
94a709c
to
9b6df7a
Compare
9b6df7a
to
4281c68
Compare
4281c68
to
cc7fdf5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, @herwinw is this good to go?
Oh sorry I didn't see your comment. Typically what I have done in those cases is put the documentation into the |
I will have a look at this to finish this one up, but that's going to be this weekend (or maybe later), I'm a bit short on time lately. |
No problem take your time! |
Part of #2123
This adds documentation for
ArrayPatternNode
,FindPatternNode
,HashPatternNode
,LocalVariableTargetNode
(a small update) andMatchRequiredNode
.