You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Red knot currently panics for the following string annotation, which is completely pointless, but not invalid syntax. The example comes from a crates/ruff_linter/resources/test/fixtures/pyflakes/F632.py and has apparently caused problems in Ruff before:
# Regression test for https://github.com/astral-sh/ruff/issues/11736
variable: "123 is not y"
I'm worried this hints at a slightly bigger problem because the panic indicates that we try to reference AST elements that were generated when re-parsing the string annotation.
Could not find expression ID for ExpressionNodeKey(NodeKey(132203792480536))
stack backtrace:
0: rust_begin_unwind
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:662:5
1: core::panicking::panic_fmt
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/panicking.rs:74:14
2: red_knot_python_semantic::semantic_index::ast_ids::AstIds::expression_id::{{closure}}
at /home/shark/ruff/crates/red_knot_python_semantic/src/semantic_index/ast_ids.rs:39:13
3: core::option::Option<T>::unwrap_or_else
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/option.rs:1010:21
4: red_knot_python_semantic::semantic_index::ast_ids::AstIds::expression_id
at /home/shark/ruff/crates/red_knot_python_semantic/src/semantic_index/ast_ids.rs:38:10
5: <ruff_python_ast::expression::ExpressionRef as red_knot_python_semantic::semantic_index::ast_ids::HasScopedExpressionId>::scoped_expression_id
at /home/shark/ruff/crates/red_knot_python_semantic/src/semantic_index/ast_ids.rs:138:9
6: <ruff_python_ast::nodes::Expr as red_knot_python_semantic::semantic_index::ast_ids::HasScopedExpressionId>::scoped_expression_id
at /home/shark/ruff/crates/red_knot_python_semantic/src/semantic_index/ast_ids.rs:95:17
7: red_knot_python_semantic::types::infer::TypeInferenceBuilder::expression_ty
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:412:28
8: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_compare_expression::{{closure}}
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:3315:35
9: core::iter::adapters::map::map_fold::{{closure}}
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/iter/adapters/map.rs:88:28
10: <core::iter::adapters::zip::Zip<A,B> as core::iter::adapters::zip::SpecFold>::spec_fold
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/iter/adapters/zip.rs:660:21
11: <core::iter::adapters::zip::Zip<A,B> as core::iter::adapters::zip::ZipImpl<A,B>>::fold
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/iter/adapters/zip.rs:250:9
12: <core::iter::adapters::zip::Zip<A,B> as core::iter::traits::iterator::Iterator>::fold
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/iter/adapters/zip.rs:104:9
13: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/iter/adapters/map.rs:128:9
14: <core::iter::adapters::enumerate::Enumerate<I> as core::iter::traits::iterator::Iterator>::fold
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/iter/adapters/enumerate.rs:113:9
15: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/iter/adapters/map.rs:128:9
16: red_knot_python_semantic::types::UnionType::from_elements
at /home/shark/ruff/crates/red_knot_python_semantic/src/types.rs:2822:9
17: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_chained_boolean_types
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:3264:9
18: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_compare_expression
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:3307:9
19: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_type_expression_no_store
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:4371:17
20: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_annotation_expression_impl
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:4171:26
21: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_annotation_expression
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:4122:29
22: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_string_annotation_expression
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:4184:17
23: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_annotation_expression_impl
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:4146:49
24: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_annotation_expression
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:4122:29
25: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_annotated_assignment_definition
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:1663:33
26: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_region_definition
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:622:17
27: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_region
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:419:56
28: red_knot_python_semantic::types::infer::TypeInferenceBuilder::finish
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:4106:9
29: <red_knot_python_semantic::types::infer::infer_definition_types::Configuration_ as salsa::function::Configuration>::execute::inner_
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:122:5
30: <red_knot_python_semantic::types::infer::infer_definition_types::Configuration_ as salsa::function::Configuration>::execute
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/components/salsa-macro-rules/src/setup_tracked_fn.rs:179:21
31: salsa::function::execute::<impl salsa::function::IngredientImpl<C>>::execute::{{closure}}
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/execute.rs:51:43
32: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/panic/unwind_safe.rs:272:9
33: std::panicking::try::do_call
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:554:40
34: __rust_try
35: std::panicking::try
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:518:19
36: std::panic::catch_unwind
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panic.rs:345:14
37: salsa::cycle::Cycle::catch
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/cycle.rs:42:15
38: salsa::function::execute::<impl salsa::function::IngredientImpl<C>>::execute
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/execute.rs:51:27
39: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::fetch_cold
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/fetch.rs:86:14
40: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::refresh_memo::{{closure}}
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/fetch.rs:36:67
41: core::option::Option<T>::or_else
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/option.rs:1545:21
42: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::refresh_memo
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/fetch.rs:36:33
43: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::fetch
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/fetch.rs:13:20
44: red_knot_python_semantic::types::infer::infer_definition_types::{{closure}}
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/components/salsa-macro-rules/src/setup_tracked_fn.rs:278:25
45: salsa::attach::Attached::attach
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/attach.rs:71:9
46: salsa::attach::attach::{{closure}}
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/attach.rs:91:23
47: std::thread::local::LocalKey<T>::try_with
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/thread/local.rs:283:12
48: std::thread::local::LocalKey<T>::with
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/thread/local.rs:260:9
49: salsa::attach::attach
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/attach.rs:91:5
50: red_knot_python_semantic::types::infer::infer_definition_types
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/components/salsa-macro-rules/src/setup_tracked_fn.rs:270:13
51: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_definition
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:898:22
52: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_annotated_assignment_statement
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:1634:13
53: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_statement
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:872:45
54: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_body
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:856:13
55: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_module
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:816:9
56: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_region_scope
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:430:17
57: red_knot_python_semantic::types::infer::TypeInferenceBuilder::infer_region
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:418:46
58: red_knot_python_semantic::types::infer::TypeInferenceBuilder::finish
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:4106:9
59: <red_knot_python_semantic::types::infer::infer_scope_types::Configuration_ as salsa::function::Configuration>::execute::inner_
at /home/shark/ruff/crates/red_knot_python_semantic/src/types/infer.rs:81:5
60: <red_knot_python_semantic::types::infer::infer_scope_types::Configuration_ as salsa::function::Configuration>::execute
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/components/salsa-macro-rules/src/setup_tracked_fn.rs:179:21
61: salsa::function::execute::<impl salsa::function::IngredientImpl<C>>::execute::{{closure}}
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/execute.rs:51:43
62: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/panic/unwind_safe.rs:272:9
63: std::panicking::try::do_call
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:554:40
64: __rust_try
65: std::panicking::try
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:518:19
66: std::panic::catch_unwind
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panic.rs:345:14
67: salsa::cycle::Cycle::catch
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/cycle.rs:42:15
68: salsa::function::execute::<impl salsa::function::IngredientImpl<C>>::execute
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/execute.rs:51:27
69: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::fetch_cold
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/fetch.rs:86:14
70: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::refresh_memo::{{closure}}
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/fetch.rs:36:67
71: core::option::Option<T>::or_else
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/option.rs:1545:21
72: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::refresh_memo
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/fetch.rs:36:33
73: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::fetch
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/function/fetch.rs:13:20
74: red_knot_python_semantic::types::infer::infer_scope_types::{{closure}}
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/components/salsa-macro-rules/src/setup_tracked_fn.rs:278:25
75: salsa::attach::Attached::attach
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/attach.rs:71:9
76: salsa::attach::attach::{{closure}}
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/attach.rs:91:23
77: std::thread::local::LocalKey<T>::try_with
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/thread/local.rs:283:12
78: std::thread::local::LocalKey<T>::with
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/thread/local.rs:260:9
79: salsa::attach::attach
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/src/attach.rs:91:5
80: red_knot_python_semantic::types::infer::infer_scope_types
at /home/shark/.cargo/git/checkouts/salsa-61760caba2b17ca5/254c749/components/salsa-macro-rules/src/setup_tracked_fn.rs:270:13
81: <ruff_python_ast::expression::ExpressionRef as red_knot_python_semantic::semantic_model::HasTy>::ty
at /home/shark/ruff/crates/red_knot_python_semantic/src/semantic_model.rs:58:9
82: <ruff_python_ast::nodes::ExprName as red_knot_python_semantic::semantic_model::HasTy>::ty
at /home/shark/ruff/crates/red_knot_python_semantic/src/semantic_model.rs:68:17
83: <ruff_python_ast::nodes::Expr as red_knot_python_semantic::semantic_model::HasTy>::ty
at /home/shark/ruff/crates/red_knot_python_semantic/src/semantic_model.rs:137:34
84: <check::PullTypesVisitor as ruff_python_ast::visitor::source_order::SourceOrderVisitor>::visit_expr
at ./tests/check.rs:250:19
85: <ruff_python_ast::nodes::StmtAnnAssign as ruff_python_ast::node::AstNode>::visit_source_order
at /home/shark/ruff/crates/ruff_python_ast/src/node.rs:1143:9
86: ruff_python_ast::visitor::source_order::walk_stmt
at /home/shark/ruff/crates/ruff_python_ast/src/visitor/source_order.rs:215:38
87: <check::PullTypesVisitor as ruff_python_ast::visitor::source_order::SourceOrderVisitor>::visit_stmt
at ./tests/check.rs:246:9
88: ruff_python_ast::visitor::source_order::walk_body
at /home/shark/ruff/crates/ruff_python_ast/src/visitor/source_order.rs:195:9
89: ruff_python_ast::visitor::source_order::SourceOrderVisitor::visit_body
at /home/shark/ruff/crates/ruff_python_ast/src/visitor/source_order.rs:146:9
90: check::pull_types
at ./tests/check.rs:181:5
91: check::run_corpus_tests::{{closure}}::{{closure}}
at ./tests/check.rs:138:54
92: std::panicking::try::do_call
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:554:40
93: __rust_try
The text was updated successfully, but these errors were encountered:
Red knot currently panics for the following string annotation, which is completely pointless, but not invalid syntax. The example comes from a
crates/ruff_linter/resources/test/fixtures/pyflakes/F632.py
and has apparently caused problems in Ruff before:ruff/crates/ruff_linter/resources/test/fixtures/pyflakes/F632.py
Lines 33 to 34 in d8538d8
I'm worried this hints at a slightly bigger problem because the panic indicates that we try to reference AST elements that were generated when re-parsing the string annotation.
The text was updated successfully, but these errors were encountered: