Document some nodes related to pattern matching#2914
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 => CONSTBut 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
4281c68 to
cc7fdf5
Compare
|
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! |
cc7fdf5 to
12a85aa
Compare
12a85aa to
0d94291
Compare
Part of #2123
This adds documentation for
ArrayPatternNode,FindPatternNode,HashPatternNode,LocalVariableTargetNode(a small update) andMatchRequiredNode.