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

Method insert

crates/ruff_python_parser/src/semantic_errors.rs:2491–2503  ·  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

2489 /// Add an identifier to the set of visited names in `self` and emit a [`SemanticSyntaxError`]
2490 /// if `ident` has already been seen.
2491 fn insert(&mut self, ident: &'a ast::Identifier) {
2492 if !self.names.insert(&ident.id) {
2493 SemanticSyntaxChecker::add_error(
2494 self.ctx,
2495 SemanticSyntaxErrorKind::MultipleCaseAssignment(ident.id.clone()),
2496 ident.range(),
2497 );
2498 }
2499 // test_err debug_shadow_match
2500 // match x:
2501 // case __debug__: ...
2502 SemanticSyntaxChecker::check_identifier(ident, self.ctx);
2503 }
2504}
2505
2506struct 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