mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 04:24:43 +00:00
Parser: impl Record
This commit is contained in:
parent
3ae3fd997b
commit
a6f9e89ffc
8 changed files with 415 additions and 172 deletions
|
@ -494,7 +494,7 @@ impl CodeGenerator {
|
|||
|
||||
fn emit_var_pat(&mut self, pat: &VarPattern, op: &Token) {
|
||||
match pat {
|
||||
VarPattern::VarName(var) => {
|
||||
VarPattern::Local(var) => {
|
||||
if op.category_is(TokenCategory::DefOp) {
|
||||
self.emit_store_instr(var.inspect().clone(), Name);
|
||||
} else {
|
||||
|
|
|
@ -780,7 +780,7 @@ impl Context {
|
|||
let vis = Private; // TODO:
|
||||
let muty = Mutability::from(&sig.inspect().unwrap()[..]);
|
||||
match &sig.pat {
|
||||
ast::VarPattern::VarName(v) => {
|
||||
ast::VarPattern::Local(v) => {
|
||||
if sig.t_spec.is_none() && opt_t.is_none() {
|
||||
Err(TyCheckError::no_type_spec_error(
|
||||
line!() as usize,
|
||||
|
@ -882,7 +882,7 @@ impl Context {
|
|||
};
|
||||
match &sig.pat {
|
||||
ast::VarPattern::Discard(_token) => Ok(()),
|
||||
ast::VarPattern::VarName(v) => {
|
||||
ast::VarPattern::Local(v) => {
|
||||
if self.registered(v.inspect(), v.inspect().is_uppercase()) {
|
||||
Err(TyCheckError::reassign_error(
|
||||
line!() as usize,
|
||||
|
@ -899,7 +899,7 @@ impl Context {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
ast::VarPattern::SelfDot(_) => todo!(),
|
||||
ast::VarPattern::Public(_) => todo!(),
|
||||
ast::VarPattern::Array(arr) => {
|
||||
for (elem, inf) in arr.iter().zip(generalized.inner_ts().iter()) {
|
||||
let id = DefId(get_hash(&(&self.name, elem)));
|
||||
|
@ -2617,7 +2617,7 @@ impl Context {
|
|||
));
|
||||
}
|
||||
}
|
||||
ast::VarPattern::VarName(n) => {
|
||||
ast::VarPattern::Local(n) => {
|
||||
if self.unify(&spec_t, body_t, None, Some(sig.loc())).is_err() {
|
||||
return Err(TyCheckError::type_mismatch_error(
|
||||
line!() as usize,
|
||||
|
|
|
@ -166,7 +166,7 @@ impl Evaluator {
|
|||
Accessor::Local(_) => None,
|
||||
Accessor::Attr(_attr) => todo!(),
|
||||
Accessor::TupleAttr(_attr) => todo!(),
|
||||
Accessor::SelfDot(_name) => todo!(),
|
||||
Accessor::Public(_name) => todo!(),
|
||||
Accessor::Subscr(_subscr) => todo!(),
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -8,7 +8,8 @@ use erg_common::value::ValueObj;
|
|||
use erg_common::Str;
|
||||
use erg_common::{
|
||||
impl_display_for_enum, impl_display_from_nested, impl_locational, impl_locational_for_enum,
|
||||
impl_nested_display_for_enum, impl_stream_for_wrapper, impl_t, impl_t_for_enum,
|
||||
impl_nested_display_for_chunk_enum, impl_nested_display_for_enum, impl_stream_for_wrapper,
|
||||
impl_t, impl_t_for_enum,
|
||||
};
|
||||
|
||||
use erg_parser::ast::{fmt_lines, DefId, Params, VarName, VarPattern};
|
||||
|
@ -1039,7 +1040,7 @@ pub enum Expr {
|
|||
Def(Def),
|
||||
}
|
||||
|
||||
impl_nested_display_for_enum!(Expr; Lit, Accessor, Array, Dict, BinOp, UnaryOp, Call, Lambda, Decl, Def);
|
||||
impl_nested_display_for_chunk_enum!(Expr; Lit, Accessor, Array, Dict, BinOp, UnaryOp, Call, Lambda, Decl, Def);
|
||||
impl_display_from_nested!(Expr);
|
||||
impl_locational_for_enum!(Expr; Lit, Accessor, Array, Dict, BinOp, UnaryOp, Call, Lambda, Decl, Def);
|
||||
impl_t_for_enum!(Expr; Lit, Accessor, Array, Dict, BinOp, UnaryOp, Call, Lambda, Decl, Def);
|
||||
|
|
|
@ -361,7 +361,7 @@ impl ASTLowerer {
|
|||
.assign_var(&sig, id, found_body_t)?;
|
||||
match block.first().unwrap() {
|
||||
hir::Expr::Call(call) => {
|
||||
if let ast::VarPattern::VarName(name) = &sig.pat {
|
||||
if let ast::VarPattern::Local(name) = &sig.pat {
|
||||
if call.is_import_call() {
|
||||
self.ctx
|
||||
.outer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue