check_repl [
"id": "MATCH-REPL",
"name": "Match recovery and persistent state",
"steps": [
[
"let \$match_saved = 9",
"quiet",
""
],
[
"let \$match_saved = match 1 { 2 => { 0 } }",
"error",
"No arm matched"
],
[
"echo \$match_saved",
"output",
"9"
],
[
"let \$match_saved = match 1 { _ => { 7 } }",
"quiet",
""
],
[
"echo \$match_saved",
"output",
"7"
],
[
"match 1 { _ => { let \$arm_private = 7; echo \$missing_arm } }",
"error",
"not found"
],
[
"echo \$arm_private",
"error",
"not found"
],
[
"match 1 { _ => {} 2 => {} }",
"error",
"wildcard match arm must be last"
],
[
"echo \"recovered\"",
"output",
"recovered"
],
[
"fn match_f(\$n): Integer { match \$n { 1 => { return 7 } _ => { 8 } } }",
"quiet",
""
],
[
"echo (match_f 1) (match_f 2)",
"output",
"7 8"
],
[
"let \$arm_range = 2..5",
"quiet",
""
],
[
"echo (match 3 { \$arm_range => { \"inside\" } _ => { \"outside\" } })",
"output",
"inside"
],
[
"\$arm_range = 7..9",
"quiet",
""
],
[
"echo (match 3 { \$arm_range => { \"inside\" } _ => { \"outside\" } })",
"output",
"outside"
]
],
"exit": 0
]