(&mut self, name: Token<'gc>, mutability: Mutability)
| 1762 | } |
| 1763 | |
| 1764 | fn declare_variable(&mut self, name: Token<'gc>, mutability: Mutability) -> usize { |
| 1765 | if self.scope_depth == 0 { |
| 1766 | return 0; |
| 1767 | } |
| 1768 | |
| 1769 | for i in (0..self.local_count).rev() { |
| 1770 | let local = &self.locals[i]; |
| 1771 | if local.is_initialized() && local.depth < self.scope_depth { |
| 1772 | // Stop when we reach an outer scope |
| 1773 | break; |
| 1774 | } |
| 1775 | if local.name.lexeme == name.lexeme { |
| 1776 | self.error_at(name, "Already a variable with this name in this scope."); |
| 1777 | // return; |
| 1778 | } |
| 1779 | } |
| 1780 | |
| 1781 | self.add_local(name, mutability) |
| 1782 | } |
| 1783 | |
| 1784 | fn update_top_local_name(&mut self, name: Token<'gc>) { |
| 1785 | self.locals[self.local_count - 1].name = name; |
no test coverage detected