Add raw identifier

This commit is contained in:
Shunsuke Shibayama 2022-10-20 18:53:35 +09:00
parent 48eb3c5920
commit 03a36f48a3
14 changed files with 137 additions and 26 deletions

View file

@ -1641,6 +1641,11 @@ impl Context {
NoneType,
);
let t_bin = nd_func(vec![kw("n", Int)], None, Str);
let t_bytes = nd_func(
vec![kw("str", Str), kw("encoding", Str)],
None,
mono("Bytes"),
);
let t_chr = nd_func(
vec![kw("i", Type::from(value(0usize)..=value(1_114_111usize)))],
None,
@ -1742,6 +1747,7 @@ impl Context {
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_py_impl("bin", t_bin, Immutable, Private, Some("bin"));
self.register_builtin_py_impl("bytes", t_bytes, Immutable, Private, Some("bytes"));
self.register_builtin_py_impl("chr", t_chr, Immutable, Private, Some("chr"));
self.register_builtin_py_impl("classof", t_classof, Immutable, Private, Some("type"));
self.register_builtin_py_impl("compile", t_compile, Immutable, Private, Some("compile"));

View file

@ -183,7 +183,7 @@ impl Context {
self.impl_of(),
py_name,
);
log!(info "Registered {}::{}: {} {:?}", self.name, ident.name, vi.t, vi.impl_of);
log!(info "Registered {}::{}: {}", self.name, ident.name, vi);
self.locals.insert(ident.name.clone(), vi);
Ok(())
}

View file

@ -841,10 +841,6 @@ impl Context {
}
Ok(())
}
hir::Expr::Decl(decl) => {
decl.t = self.deref_tyvar(mem::take(&mut decl.t), Covariant, decl.loc())?;
Ok(())
}
hir::Expr::Def(def) => {
// It is not possible to further dereference the quantified type.
// TODO: However, it is possible that there are external type variables within the quantified type.