fn declare_variable(
        &mut self,
        name: &str,
        kind: SymbolKind,
        span: &Span,
    ) -> Result<(), SyntaxError> {
        let depth = self.scopes.len() - 1;

        let symbol = Symbol::new(kind, span, depth);

        if let Some(Symbol(_, prev_pos, _)) = self.local_scope().add_local(name, symbol) {
            return Err(self.duplicate_ids(name, span, &prev_pos));
        }

        Ok(())
    }
/// Add a variable to the current scope, checking for duplicates.
Add a variable to the current scope, checking for duplicates.
Add a variable to the current scope checking for duplicates .
fn declare_variable(
        &mut self,
        name: &str,
        kind: SymbolKind,
        span: &Span,
    ) -> Result<(), SyntaxError> {
        let depth = self.scopes.len() - 1;
        let symbol = Symbol::new(kind, span, depth);
        if let Some(Symbol(_, prev_pos, _)) = self.local_scope().add_local(name, symbol) {
            return Err(self.duplicate_ids(name, span, &prev_pos));
        }
        Ok(())
    }
fn declare_variable ( & mut self , name : & str , kind : SymbolKind , span : & Span , ) -> Result < ( ) , SyntaxError > { let depth = self . scopes . len ( ) - 1 ; let symbol = Symbol :: new ( kind , span , depth ) ; if let Some ( Symbol ( _ , prev_pos , _ ) ) = self . local_scope ( ) . add_local ( name , symbol ) { return Err ( self . duplicate_ids ( name , span , & prev_pos ) ) ; } Ok ( ( ) ) }
Add a variable to the current scope, checking for duplicates.
Add a variable to the current scope checking for duplicates .
&mut self
name
&str
kind
SymbolKind
span
&Span