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,
|
Signature::Var(_) => None,
|
||||||
};
|
};
|
||||||
// TODO: set params
|
// 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| {
|
let obj = self.eval_const_block(&def.body.block).map_err(|e| {
|
||||||
self.pop();
|
self.pop();
|
||||||
e
|
e
|
||||||
|
|
|
@ -40,7 +40,7 @@ use erg_parser::ast;
|
||||||
use erg_parser::token::Token;
|
use erg_parser::token::Token;
|
||||||
|
|
||||||
use crate::context::instantiate::{ConstTemplate, TyVarInstContext};
|
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::mod_cache::SharedModuleCache;
|
||||||
use crate::varinfo::{Mutability, ParamIdx, VarInfo, VarKind};
|
use crate::varinfo::{Mutability, ParamIdx, VarInfo, VarKind};
|
||||||
use Visibility::*;
|
use Visibility::*;
|
||||||
|
@ -841,7 +841,7 @@ impl Context {
|
||||||
kind: ContextKind,
|
kind: ContextKind,
|
||||||
vis: Visibility,
|
vis: Visibility,
|
||||||
tv_ctx: Option<TyVarInstContext>,
|
tv_ctx: Option<TyVarInstContext>,
|
||||||
) -> TyCheckResult<()> {
|
) {
|
||||||
let name = if vis.is_public() {
|
let name = if vis.is_public() {
|
||||||
format!("{parent}.{name}", parent = self.name)
|
format!("{parent}.{name}", parent = self.name)
|
||||||
} else {
|
} else {
|
||||||
|
@ -855,7 +855,6 @@ impl Context {
|
||||||
self.tv_ctx = tv_ctx;
|
self.tv_ctx = tv_ctx;
|
||||||
self.name = name.into();
|
self.name = name.into();
|
||||||
self.kind = kind;
|
self.kind = kind;
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pop(&mut self) -> Context {
|
pub fn pop(&mut self) -> Context {
|
||||||
|
|
|
@ -526,7 +526,7 @@ impl Context {
|
||||||
let bounds = self.instantiate_ty_bounds(&sig.bounds, PreRegister)?;
|
let bounds = self.instantiate_ty_bounds(&sig.bounds, PreRegister)?;
|
||||||
let tv_ctx = TyVarInstContext::new(self.level, bounds, self);
|
let tv_ctx = TyVarInstContext::new(self.level, bounds, self);
|
||||||
let vis = def.sig.vis();
|
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) {
|
let (obj, const_t) = match self.eval_const_block(&def.body.block) {
|
||||||
Ok(obj) => (obj.clone(), v_enum(set! {obj})),
|
Ok(obj) => (obj.clone(), v_enum(set! {obj})),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
@ -545,7 +545,7 @@ impl Context {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::Signature::Var(sig) if sig.is_const() => {
|
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) {
|
let (obj, const_t) = match self.eval_const_block(&def.body.block) {
|
||||||
Ok(obj) => (obj.clone(), v_enum(set! {obj})),
|
Ok(obj) => (obj.clone(), v_enum(set! {obj})),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
|
@ -334,8 +334,7 @@ impl ASTLowerer {
|
||||||
log!(info "entered {}({record})", fn_name!());
|
log!(info "entered {}({record})", fn_name!());
|
||||||
let mut hir_record =
|
let mut hir_record =
|
||||||
hir::Record::new(record.l_brace, record.r_brace, hir::RecordAttrs::empty());
|
hir::Record::new(record.l_brace, record.r_brace, hir::RecordAttrs::empty());
|
||||||
self.ctx
|
self.ctx.grow("<record>", ContextKind::Dummy, Private, None);
|
||||||
.grow("<record>", ContextKind::Dummy, Private, None)?;
|
|
||||||
for attr in record.attrs.into_iter() {
|
for attr in record.attrs.into_iter() {
|
||||||
let attr = self.lower_def(attr).map_err(|e| {
|
let attr = self.lower_def(attr).map_err(|e| {
|
||||||
self.pop_append_errs();
|
self.pop_append_errs();
|
||||||
|
@ -786,7 +785,7 @@ impl ASTLowerer {
|
||||||
.ctx
|
.ctx
|
||||||
.instantiate_ty_bounds(&lambda.sig.bounds, RegistrationMode::Normal)?;
|
.instantiate_ty_bounds(&lambda.sig.bounds, RegistrationMode::Normal)?;
|
||||||
let tv_ctx = TyVarInstContext::new(self.ctx.level, bounds, &self.ctx);
|
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) {
|
if let Err(errs) = self.ctx.assign_params(&lambda.sig.params, None) {
|
||||||
self.errs.extend(errs.into_iter());
|
self.errs.extend(errs.into_iter());
|
||||||
}
|
}
|
||||||
|
@ -870,11 +869,11 @@ impl ASTLowerer {
|
||||||
.ctx
|
.ctx
|
||||||
.instantiate_ty_bounds(&sig.bounds, RegistrationMode::Normal)?;
|
.instantiate_ty_bounds(&sig.bounds, RegistrationMode::Normal)?;
|
||||||
let tv_ctx = TyVarInstContext::new(self.ctx.level, bounds, &self.ctx);
|
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)
|
self.lower_subr_def(sig, def.body)
|
||||||
}
|
}
|
||||||
ast::Signature::Var(sig) => {
|
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)
|
self.lower_var_def(sig, def.body)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1083,7 +1082,7 @@ impl ASTLowerer {
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
self.ctx
|
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() {
|
for def in methods.defs.iter_mut() {
|
||||||
if methods.vis.is(TokenKind::Dot) {
|
if methods.vis.is(TokenKind::Dot) {
|
||||||
def.sig.ident_mut().unwrap().dot = Some(Token::new(
|
def.sig.ident_mut().unwrap().dot = Some(Token::new(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue