MCPcopy Create free account
hub / github.com/astral-sh/ruff / insert

Method insert

crates/ruff_python_parser/src/semantic_errors.rs:2499–2511  ·  view source on GitHub ↗

Add an identifier to the set of visited names in `self` and emit a [`SemanticSyntaxError`] if `ident` has already been seen.

(&mut self, ident: &'a ast::Identifier)

Source from the content-addressed store, hash-verified

2497 /// Add an identifier to the set of visited names in `self` and emit a [`SemanticSyntaxError`]
2498 /// if `ident` has already been seen.
2499 fn insert(&mut self, ident: &'a ast::Identifier) {
2500 if !self.names.insert(&ident.id) {
2501 SemanticSyntaxChecker::add_error(
2502 self.ctx,
2503 SemanticSyntaxErrorKind::MultipleCaseAssignment(ident.id.clone()),
2504 ident.range(),
2505 );
2506 }
2507 // test_err debug_shadow_match
2508 // match x:
2509 // case __debug__: ...
2510 SemanticSyntaxChecker::check_identifier(ident, self.ctx);
2511 }
2512}
2513
2514struct InvalidExpressionVisitor<'a, Ctx> {

Callers 5

visit_patternMethod · 0.45
try_fromMethod · 0.45
existing_testsFunction · 0.45

Calls 2

cloneMethod · 0.45
rangeMethod · 0.45

Tested by 2

try_fromMethod · 0.36
existing_testsFunction · 0.36