mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 20:34:44 +00:00
Add unreachable
This commit is contained in:
parent
4068a5ba07
commit
52a00930f4
2 changed files with 11 additions and 2 deletions
|
@ -1800,6 +1800,7 @@ impl Context {
|
||||||
let t_exit = t_quit.clone();
|
let t_exit = t_quit.clone();
|
||||||
let t_repr = nd_func(vec![kw("object", Obj)], None, Str);
|
let t_repr = nd_func(vec![kw("object", Obj)], None, Str);
|
||||||
let t_round = nd_func(vec![kw("number", Float)], None, Int);
|
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("abs", t_abs, Immutable, Private, Some("abs"));
|
||||||
self.register_builtin_py_impl("ascii", t_ascii, Immutable, Private, Some("ascii"));
|
self.register_builtin_py_impl("ascii", t_ascii, Immutable, Private, Some("ascii"));
|
||||||
self.register_builtin_impl("assert", t_assert, Const, Private); // assert casting に悪影響が出る可能性があるため、Constとしておく
|
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("quit", t_quit, Immutable, Private, Some("quit"));
|
||||||
self.register_builtin_py_impl("repr", t_repr, Immutable, Private, Some("repr"));
|
self.register_builtin_py_impl("repr", t_repr, Immutable, Private, Some("repr"));
|
||||||
self.register_builtin_py_impl("round", t_round, Immutable, Private, Some("round"));
|
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) {
|
fn init_builtin_const_funcs(&mut self) {
|
||||||
|
|
|
@ -3,9 +3,9 @@ sum2 [x, y]: [Nat; 2] =
|
||||||
|
|
||||||
print! sum2 [1, 2]
|
print! sum2 [1, 2]
|
||||||
|
|
||||||
x = match "c" + "":
|
x = match "a" + "":
|
||||||
"a" -> 1
|
"a" -> 1
|
||||||
"b" -> 2
|
"b" -> 2
|
||||||
_ -> 3
|
_ -> unreachable()
|
||||||
|
|
||||||
print! x
|
print! x
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue