Add unreachable

This commit is contained in:
Shunsuke Shibayama 2022-10-23 01:01:24 +09:00
parent 4068a5ba07
commit 52a00930f4
2 changed files with 11 additions and 2 deletions

View file

@ -1800,6 +1800,7 @@ impl Context {
let t_exit = t_quit.clone();
let t_repr = nd_func(vec![kw("object", Obj)], None, Str);
let t_round = nd_func(vec![kw("number", Float)], None, Int);
let t_unreachable = nd_func(vec![], None, Never);
self.register_builtin_py_impl("abs", t_abs, Immutable, Private, Some("abs"));
self.register_builtin_py_impl("ascii", t_ascii, Immutable, Private, Some("ascii"));
self.register_builtin_impl("assert", t_assert, Const, Private); // assert casting に悪影響が出る可能性があるため、Constとしておく
@ -1852,6 +1853,14 @@ impl Context {
self.register_builtin_py_impl("quit", t_quit, Immutable, Private, Some("quit"));
self.register_builtin_py_impl("repr", t_repr, Immutable, Private, Some("repr"));
self.register_builtin_py_impl("round", t_round, Immutable, Private, Some("round"));
// TODO: original implementation
self.register_builtin_py_impl(
"unreachable",
t_unreachable,
Immutable,
Private,
Some("exit"),
);
}
fn init_builtin_const_funcs(&mut self) {

View file

@ -3,9 +3,9 @@ sum2 [x, y]: [Nat; 2] =
print! sum2 [1, 2]
x = match "c" + "":
x = match "a" + "":
"a" -> 1
"b" -> 2
_ -> 3
_ -> unreachable()
print! x