Skip to content

SymbolTableType::Lambda #5942

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

Merged
merged 1 commit into from
Jul 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions compiler/codegen/src/symboltable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ pub enum SymbolTableType {
Module,
Class,
Function,
Lambda,
Comprehension,
TypeParams,
}
Expand All @@ -90,6 +91,7 @@ impl fmt::Display for SymbolTableType {
Self::Module => write!(f, "module"),
Self::Class => write!(f, "class"),
Self::Function => write!(f, "function"),
Self::Lambda => write!(f, "lambda"),
Self::Comprehension => write!(f, "comprehension"),
Self::TypeParams => write!(f, "type parameter"),
// TODO missing types from the C implementation
Expand Down Expand Up @@ -493,7 +495,7 @@ impl SymbolTableAnalyzer {
location: None,
});
}
SymbolTableType::Function => {
SymbolTableType::Function | SymbolTableType::Lambda => {
if let Some(parent_symbol) = symbols.get_mut(&symbol.name) {
if let SymbolScope::Unknown = parent_symbol.scope {
// this information is new, as the assignment is done in inner scope
Expand Down Expand Up @@ -1140,7 +1142,7 @@ impl SymbolTableBuilder<'_> {
} else {
self.enter_scope(
"lambda",
SymbolTableType::Function,
SymbolTableType::Lambda,
self.line_index_start(expression.range()),
);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/core/src/bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ op_arg_enum!(
// PrepReraiseS tar = 1,
// TypeVarWithBound = 2,
// TypeVarWithConstraints = 3,
// SetFunctionTypeParams = 4,
SetFunctionTypeParams = 4,
/// Set default value for type parameter (PEP 695)
SetTypeparamDefault = 5,
}
Expand Down
6 changes: 6 additions & 0 deletions vm/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2286,6 +2286,12 @@ impl ExecutingFrame<'_> {
bytecode::IntrinsicFunction2::SetTypeparamDefault => {
crate::stdlib::typing::set_typeparam_default(arg1, arg2, vm)
}
bytecode::IntrinsicFunction2::SetFunctionTypeParams => {
// arg1 is the function, arg2 is the type params tuple
// Set __type_params__ attribute on the function
arg1.set_attr("__type_params__", arg2, vm)?;
Ok(arg1)
}
}
}

Expand Down