Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Red Knot - Add symbol flags #11134

Merged
merged 18 commits into from
Apr 30, 2024
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
60013e8
[red-knot] add flags to symbols::Symbol
plredmond Apr 24, 2024
03b090d
[red-knot] sketch out remaining flag work
plredmond Apr 24, 2024
2b5f83e
[red-knot] rename Disposition to Kind
plredmond Apr 25, 2024
2d5a8f7
[red-knot] clippy
plredmond Apr 25, 2024
9c6a8bc
[red-knot] missing argument in test
plredmond Apr 25, 2024
dcedac4
[red-knot] uncomment the Symbol.kind field even though it is still todo
plredmond Apr 29, 2024
f80395c
[red-knot] rename 3 add_symbol_* methods per @carljm recs in #11134
plredmond Apr 29, 2024
ca3d854
[red-knot] wait, no, do not uncomment that field b/c no idea what to …
plredmond Apr 29, 2024
adadc9b
[red-knot] test that flags are added and merged by method
plredmond Apr 29, 2024
e9f72ef
[red-knot] test that a definition has is_defined but not is_used
plredmond Apr 29, 2024
6a637f6
[red-knot] fix incorrect names that crept in during rebase
plredmond Apr 29, 2024
0c801b6
[red-knot] fix incorrect flags logic that crept in during rebase
plredmond Apr 29, 2024
8ebe0e5
[red-knot] assertion showing that a symbol used but not defined has c…
plredmond Apr 29, 2024
391e68a
[red-knot] per @carljm, type params are defined by the scope that int…
plredmond Apr 29, 2024
389c2c3
[red-knot] test assertion that type params are defined by the scope t…
plredmond Apr 29, 2024
c5427d0
[red-knot] change pattern match to flag check in SymbolTableBuilder::…
plredmond Apr 29, 2024
eb007a8
[red-knot] todo noting that MARK_GLOBAL and MARK_NONLOCAL are not yet…
plredmond Apr 29, 2024
07d99a7
[red-knot] add CellVarAssigned to Symbol Kind enum
plredmond Apr 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[red-knot] fix incorrect flags logic that crept in during rebase
  • Loading branch information
plredmond committed Apr 29, 2024
commit 0c801b62caa9fa291763a63ffaa90beb4894fa13
8 changes: 7 additions & 1 deletion crates/red_knot/src/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,13 @@ impl SymbolTableBuilder {
impl PreorderVisitor<'_> for SymbolTableBuilder {
fn visit_expr(&mut self, expr: &ast::Expr) {
if let ast::Expr::Name(ast::ExprName { id, ctx, .. }) = expr {
self.add_or_update_symbol(id, SymbolFlags::empty());
let flags = match ctx {
ast::ExprContext::Load => SymbolFlags::IS_USED,
ast::ExprContext::Store => SymbolFlags::IS_DEFINED,
ast::ExprContext::Del => SymbolFlags::IS_DEFINED,
ast::ExprContext::Invalid => SymbolFlags::empty(),
};
self.add_or_update_symbol(id, flags);
if matches!(ctx, ast::ExprContext::Store | ast::ExprContext::Del) {
plredmond marked this conversation as resolved.
Show resolved Hide resolved
if let Some(curdef) = self.current_definition.clone() {
self.add_or_update_symbol_with_def(id, curdef);
Expand Down
Loading