fn define_local(&mut self, loc: &Loc, name: Symbol, type_: Type, operation: Option<Operation>) {
        let entry = LocalVarEntry {
            loc: loc.clone(),
            type_,
            operation,
        };
        if let Some(old) = self
            .local_table
            .front_mut()
            .expect("symbol table empty")
            .insert(name, entry)
        {
            let display = name.display(self.symbol_pool());
            self.error(loc, &format!("duplicate declaration of `{}`", display));
            self.error(&old.loc, &format!("previous declaration of `{}`", display));
        } else {
            // Check whether we do not shadow a variable.
            // TODO(wrwg): remove once we have sorted out correct implementation of
            //   shadowing. Currently there are some bugs, so better to disallow it.
            for scope in self.local_table.iter().skip(1) {
                if let Some(old_loc) = scope.get(&name).map(|e| e.loc.clone()) {
                    let display = name.display(self.symbol_pool());
                    self.error(
                        loc,
                        &format!(
                            "shadowing of declaration of `{}` not allowed \
                    (current implementation restriction)",
                            display
                        ),
                    );
                    self.error(&old_loc, &format!("previous declaration of `{}`", display));
                    break;
                }
            }
        }
    }
/// Defines a local in the most inner scope. This produces an error
/// if the name already exists. The operation option is used for names
/// which represent special operations.
Defines a local in the most inner scope. This produces an error
if the name already exists. The operation option is used for names
which represent special operations.
Defines a local in the most inner scope . This produces an error if the name already exists . The operation option is used for names which represent special operations .
fn define_local(&mut self, loc: &Loc, name: Symbol, type_: Type, operation: Option<Operation>) {
        let entry = LocalVarEntry {
            loc: loc.clone(),
            type_,
            operation,
        };
        if let Some(old) = self
            .local_table
            .front_mut()
            .expect("symbol table empty")
            .insert(name, entry)
        {
            let display = name.display(self.symbol_pool());
            self.error(loc, &format!("duplicate declaration of `{}`", display));
            self.error(&old.loc, &format!("previous declaration of `{}`", display));
        } else {
            // Check whether we do not shadow a variable.
            // TODO(wrwg): remove once we have sorted out correct implementation of
            //   shadowing. Currently there are some bugs, so better to disallow it.
            for scope in self.local_table.iter().skip(1) {
                if let Some(old_loc) = scope.get(&name).map(|e| e.loc.clone()) {
                    let display = name.display(self.symbol_pool());
                    self.error(
                        loc,
                        &format!(
                            "shadowing of declaration of `{}` not allowed \
                    (current implementation restriction)",
                            display
                        ),
                    );
                    self.error(&old_loc, &format!("previous declaration of `{}`", display));
                    break;
                }
            }
        }
    }
fn define_local ( & mut self , loc : & Loc , name : Symbol , type_ : Type , operation : Option < Operation > ) { let entry = LocalVarEntry { loc : loc . clone ( ) , type_ , operation , } ; if let Some ( old ) = self . local_table . front_mut ( ) . expect ( " " ) . insert ( name , entry ) { let display = name . display ( self . symbol_pool ( ) ) ; self . error ( loc , & format ! ( " " display ) ) ; self . error ( & old . loc , & format ! ( " " display ) ) ; } else { // Check whether we do not shadow a variable. // TODO(wrwg): remove once we have sorted out correct implementation of //   shadowing. Currently there are some bugs, so better to disallow it. for scope in self . local_table . iter ( ) . skip ( 1 ) { if let Some ( old_loc ) = scope . get ( & name ) . map ( | e | e . loc . clone ( ) ) { let display = name . display ( self . symbol_pool ( ) ) ; self . error ( loc , & format ! ( " \
 " display ) , ) ; self . error ( & old_loc , & format ! ( " " display ) ) ; break ; } } } }
Defines a local in the most inner scope.
Defines a local in the most inner scope .
&mut self
loc
&Loc
name
Symbol
type_
Type
operation
Option<Operation>
&mut self
loc
&Loc
name
Symbol
type_
Type
operation
Option<Operation>