Commit 860bad77
860bad77bae8Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified
Description
Merge pull request #954 from ryanseys/rs-pattern-no-match-error
codegen: case/in raises NoMatchingPatternError on exhaustive miss
Details
- Commit
- 860bad77bae8
- Parent
- 268c9fa0dbe7
- Merge parent
- cd4d3f6bf26f
spinel_codegen.rbmodifiedView file
@@ -8567,6 +8567,8 @@
85678567
["SystemCallError", "StandardError"],85688568
["LocalJumpError", "StandardError"],85698569
["FiberError", "StandardError"],8570+
["NoMatchingPatternError", "StandardError"],8571+
["NoMatchingPatternKeyError", "NoMatchingPatternError"],85708572
["Exception", ""],85718573
]85728574
bp = 0@@ -33061,6 +33063,17 @@
3306133063
@indent = @indent + 13306233064
compile_stmts_body(@nd_body[ec])3306333065
@indent = @indent - 133066+
elsif conds.length > 033067+
# No `else` clause: CRuby raises NoMatchingPatternError when no33068+
# `in` arm matched. The message includes the inspected scrutinee33069+
# value (we drop the `=== val does not return true` tail since33070+
# spinel doesn't carry the pattern's source text at codegen).33071+
ins_msg = compile_inspect_for(pred_type, tmp)33072+
if ins_msg != ""33073+
emit(" } else { sp_raise_cls(\"NoMatchingPatternError\", " + ins_msg + ");")33074+
else33075+
emit(" } else { sp_raise_cls(\"NoMatchingPatternError\", \"no matching pattern\");")33076+
end3306433077
end3306533078
if conds.length > 03306633079
emit(" }")test/case_in_no_match_error.rbaddedView file
Loading diff…
test/case_in_no_match_error.rb.expectedaddedView file
Loading diff…