MCPcopy Index your code
hub / github.com/RustPython/RustPython / check_name

Method check_name

crates/codegen/src/symboltable.rs:2551–2580  ·  view source on GitHub ↗
(
        &self,
        name: &str,
        context: ExpressionContext,
        range: TextRange,
    )

Source from the content-addressed store, hash-verified

2549 }
2550
2551 fn check_name(
2552 &self,
2553 name: &str,
2554 context: ExpressionContext,
2555 range: TextRange,
2556 ) -> SymbolTableResult {
2557 if name == "__debug__" {
2558 let location = Some(
2559 self.source_file
2560 .to_source_code()
2561 .source_location(range.start(), PositionEncoding::Utf8),
2562 );
2563 match context {
2564 ExpressionContext::Store | ExpressionContext::Iter => {
2565 return Err(SymbolTableError {
2566 error: "cannot assign to __debug__".to_owned(),
2567 location,
2568 });
2569 }
2570 ExpressionContext::Delete => {
2571 return Err(SymbolTableError {
2572 error: "cannot delete __debug__".to_owned(),
2573 location,
2574 });
2575 }
2576 _ => {}
2577 }
2578 }
2579 Ok(())
2580 }
2581
2582 fn register_name(
2583 &mut self,

Callers 3

scan_parameterMethod · 0.80
scan_statementMethod · 0.80
scan_expressionMethod · 0.80

Calls 5

source_locationMethod · 0.80
SomeClass · 0.50
ErrClass · 0.50
startMethod · 0.45
to_ownedMethod · 0.45

Tested by

no test coverage detected