mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 12:24:45 +00:00
Change grow
's type
This commit is contained in:
parent
98460202df
commit
145152575c
4 changed files with 10 additions and 12 deletions
|
@ -432,7 +432,7 @@ impl Context {
|
|||
Signature::Var(_) => None,
|
||||
};
|
||||
// TODO: set params
|
||||
self.grow(__name__, ContextKind::Instant, vis, tv_ctx)?;
|
||||
self.grow(__name__, ContextKind::Instant, vis, tv_ctx);
|
||||
let obj = self.eval_const_block(&def.body.block).map_err(|e| {
|
||||
self.pop();
|
||||
e
|
||||
|
|
|
@ -40,7 +40,7 @@ use erg_parser::ast;
|
|||
use erg_parser::token::Token;
|
||||
|
||||
use crate::context::instantiate::{ConstTemplate, TyVarInstContext};
|
||||
use crate::error::{SingleTyCheckResult, TyCheckError, TyCheckErrors, TyCheckResult};
|
||||
use crate::error::{SingleTyCheckResult, TyCheckError, TyCheckErrors};
|
||||
use crate::mod_cache::SharedModuleCache;
|
||||
use crate::varinfo::{Mutability, ParamIdx, VarInfo, VarKind};
|
||||
use Visibility::*;
|
||||
|
@ -841,7 +841,7 @@ impl Context {
|
|||
kind: ContextKind,
|
||||
vis: Visibility,
|
||||
tv_ctx: Option<TyVarInstContext>,
|
||||
) -> TyCheckResult<()> {
|
||||
) {
|
||||
let name = if vis.is_public() {
|
||||
format!("{parent}.{name}", parent = self.name)
|
||||
} else {
|
||||
|
@ -855,7 +855,6 @@ impl Context {
|
|||
self.tv_ctx = tv_ctx;
|
||||
self.name = name.into();
|
||||
self.kind = kind;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn pop(&mut self) -> Context {
|
||||
|
|
|
@ -526,7 +526,7 @@ impl Context {
|
|||
let bounds = self.instantiate_ty_bounds(&sig.bounds, PreRegister)?;
|
||||
let tv_ctx = TyVarInstContext::new(self.level, bounds, self);
|
||||
let vis = def.sig.vis();
|
||||
self.grow(__name__, ContextKind::Proc, vis, Some(tv_ctx))?;
|
||||
self.grow(__name__, ContextKind::Proc, vis, Some(tv_ctx));
|
||||
let (obj, const_t) = match self.eval_const_block(&def.body.block) {
|
||||
Ok(obj) => (obj.clone(), v_enum(set! {obj})),
|
||||
Err(e) => {
|
||||
|
@ -545,7 +545,7 @@ impl Context {
|
|||
}
|
||||
}
|
||||
ast::Signature::Var(sig) if sig.is_const() => {
|
||||
self.grow(__name__, ContextKind::Instant, sig.vis(), None)?;
|
||||
self.grow(__name__, ContextKind::Instant, sig.vis(), None);
|
||||
let (obj, const_t) = match self.eval_const_block(&def.body.block) {
|
||||
Ok(obj) => (obj.clone(), v_enum(set! {obj})),
|
||||
Err(e) => {
|
||||
|
|
|
@ -334,8 +334,7 @@ impl ASTLowerer {
|
|||
log!(info "entered {}({record})", fn_name!());
|
||||
let mut hir_record =
|
||||
hir::Record::new(record.l_brace, record.r_brace, hir::RecordAttrs::empty());
|
||||
self.ctx
|
||||
.grow("<record>", ContextKind::Dummy, Private, None)?;
|
||||
self.ctx.grow("<record>", ContextKind::Dummy, Private, None);
|
||||
for attr in record.attrs.into_iter() {
|
||||
let attr = self.lower_def(attr).map_err(|e| {
|
||||
self.pop_append_errs();
|
||||
|
@ -786,7 +785,7 @@ impl ASTLowerer {
|
|||
.ctx
|
||||
.instantiate_ty_bounds(&lambda.sig.bounds, RegistrationMode::Normal)?;
|
||||
let tv_ctx = TyVarInstContext::new(self.ctx.level, bounds, &self.ctx);
|
||||
self.ctx.grow(&name, kind, Private, Some(tv_ctx))?;
|
||||
self.ctx.grow(&name, kind, Private, Some(tv_ctx));
|
||||
if let Err(errs) = self.ctx.assign_params(&lambda.sig.params, None) {
|
||||
self.errs.extend(errs.into_iter());
|
||||
}
|
||||
|
@ -870,11 +869,11 @@ impl ASTLowerer {
|
|||
.ctx
|
||||
.instantiate_ty_bounds(&sig.bounds, RegistrationMode::Normal)?;
|
||||
let tv_ctx = TyVarInstContext::new(self.ctx.level, bounds, &self.ctx);
|
||||
self.ctx.grow(&name, kind, vis, Some(tv_ctx))?;
|
||||
self.ctx.grow(&name, kind, vis, Some(tv_ctx));
|
||||
self.lower_subr_def(sig, def.body)
|
||||
}
|
||||
ast::Signature::Var(sig) => {
|
||||
self.ctx.grow(&name, kind, vis, None)?;
|
||||
self.ctx.grow(&name, kind, vis, None);
|
||||
self.lower_var_def(sig, def.body)
|
||||
}
|
||||
};
|
||||
|
@ -1083,7 +1082,7 @@ impl ASTLowerer {
|
|||
)));
|
||||
}
|
||||
self.ctx
|
||||
.grow(&class.local_name(), ContextKind::MethodDefs, Private, None)?;
|
||||
.grow(&class.local_name(), ContextKind::MethodDefs, Private, None);
|
||||
for def in methods.defs.iter_mut() {
|
||||
if methods.vis.is(TokenKind::Dot) {
|
||||
def.sig.ident_mut().unwrap().dot = Some(Token::new(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue