mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-03 05:54:33 +00:00
Add trim_end_proc_mark
This commit is contained in:
parent
055b6117ff
commit
855d463011
2 changed files with 19 additions and 2 deletions
|
@ -1909,7 +1909,10 @@ impl ASTLowerer {
|
||||||
let is_instance_ascription = tasc.is_instance_ascription();
|
let is_instance_ascription = tasc.is_instance_ascription();
|
||||||
let mut dummy_tv_cache = TyVarCache::new(self.ctx.level, &self.ctx);
|
let mut dummy_tv_cache = TyVarCache::new(self.ctx.level, &self.ctx);
|
||||||
match *tasc.expr {
|
match *tasc.expr {
|
||||||
ast::Expr::Accessor(ast::Accessor::Ident(ident)) => {
|
ast::Expr::Accessor(ast::Accessor::Ident(mut ident)) => {
|
||||||
|
if self.cfg.pylyzer_mode {
|
||||||
|
ident.trim_end_proc_mark();
|
||||||
|
}
|
||||||
let py_name = Str::rc(ident.inspect().trim_end_matches('!'));
|
let py_name = Str::rc(ident.inspect().trim_end_matches('!'));
|
||||||
let t = self.ctx.instantiate_typespec(
|
let t = self.ctx.instantiate_typespec(
|
||||||
&tasc.t_spec,
|
&tasc.t_spec,
|
||||||
|
@ -1932,7 +1935,10 @@ impl ASTLowerer {
|
||||||
let ident = hir::Identifier::new(ident.dot, ident.name, None, vi);
|
let ident = hir::Identifier::new(ident.dot, ident.name, None, vi);
|
||||||
Ok(hir::Expr::Accessor(hir::Accessor::Ident(ident)).type_asc(tasc.t_spec))
|
Ok(hir::Expr::Accessor(hir::Accessor::Ident(ident)).type_asc(tasc.t_spec))
|
||||||
}
|
}
|
||||||
ast::Expr::Accessor(ast::Accessor::Attr(attr)) => {
|
ast::Expr::Accessor(ast::Accessor::Attr(mut attr)) => {
|
||||||
|
if self.cfg.pylyzer_mode {
|
||||||
|
attr.ident.trim_end_proc_mark();
|
||||||
|
}
|
||||||
let py_name = Str::rc(attr.ident.inspect().trim_end_matches('!'));
|
let py_name = Str::rc(attr.ident.inspect().trim_end_matches('!'));
|
||||||
let t = self.ctx.instantiate_typespec(
|
let t = self.ctx.instantiate_typespec(
|
||||||
&tasc.t_spec,
|
&tasc.t_spec,
|
||||||
|
|
|
@ -2295,6 +2295,13 @@ impl VarName {
|
||||||
pub const fn inspect(&self) -> &Str {
|
pub const fn inspect(&self) -> &Str {
|
||||||
&self.0.content
|
&self.0.content
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Remove `!` from the end of the identifier.
|
||||||
|
/// Procedures defined in `d.er` automatically register the name without `!` as `py_name`.
|
||||||
|
/// This method is for undoing it (e.g. pylyzer-mode)
|
||||||
|
pub fn trim_end_proc_mark(&mut self) {
|
||||||
|
let _ = self.0.content.trim_end_matches('!');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -2378,6 +2385,10 @@ impl Identifier {
|
||||||
pub fn is_procedural(&self) -> bool {
|
pub fn is_procedural(&self) -> bool {
|
||||||
self.name.is_procedural()
|
self.name.is_procedural()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn trim_end_proc_mark(&mut self) {
|
||||||
|
self.name.trim_end_proc_mark();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue