Fix multiline array/dictionary match statements
Currently array and dictionary expressions cannot be spread over multiple lines in match statements. Adding mutliline push/pop while parsing the pattern for bracket and brace enables the ability for these to be multiline. This enables more complex patterns to be matched without exceeding line limits. Fixes #90372
This commit is contained in:
parent
b2f425fe68
commit
74177d79c9
5 changed files with 82 additions and 15 deletions
|
|
@ -26,6 +26,24 @@ func bar(x):
|
|||
_:
|
||||
print("wildcard")
|
||||
|
||||
func baz(x):
|
||||
match x:
|
||||
{
|
||||
"key1": "value1"
|
||||
}:
|
||||
print('multiline {"key1": "value1"}')
|
||||
{
|
||||
"key2": "value2",
|
||||
}:
|
||||
print('multiline {"key2": "value2",}')
|
||||
{
|
||||
"key3": {
|
||||
"key1",
|
||||
..,
|
||||
},
|
||||
}:
|
||||
print('multiline {"key3": {"key1", ..,},}')
|
||||
|
||||
func test():
|
||||
foo({"key1": "value1", "key2": "value2"})
|
||||
foo({"key1": "value1", "key2": ""})
|
||||
|
|
@ -41,3 +59,6 @@ func test():
|
|||
bar({1: "1"})
|
||||
bar({2: "2"})
|
||||
bar({3: "3"})
|
||||
baz({"key1": "value1"})
|
||||
baz({"key2": "value2"})
|
||||
baz({"key3": {"key1": "value1", "key2": "value2"}})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue