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
Core: Resolve assignment targets local-first, and reject global on a parameter
Reads resolve a name local-first (_handle_name_expr, get_operand_value, the
printk formatter), but both write paths checked the declared-global set
before local_sym_tab. Normally harmless because the two tables are disjoint
by construction -- except for a parameter whose name matches a @bpfglobal.
With 'global ctx' in a function taking ctx, the write path stored to the
global while a read of the same name picked the parameter and crashed on its
None slot: the same name resolving to different storage depending on which
side of an assignment it sat.
Python forbids the construct outright, and now so does the compiler, with
Python's own wording: SyntaxError: name 'ctx' is parameter and global. Both
write paths now resolve local-first like the reads, so all name lookups read
the same way; and an augmented assignment to the context parameter itself
gets a clear error instead of a store to None.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BSDVsZH5NtoASyxB8FCtGU
Copy file name to clipboardExpand all lines: tests/test_config.toml
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -40,3 +40,5 @@
40
40
"failing_tests/globals_bad_type.py" = {reason = "Non-integer-scalar globals are not supported in milestone 1 (NotImplementedError by design)", level = "ir"}
41
41
42
42
"failing_tests/globals_augassign_shadowing.py" = {reason = "Augmented assignment to a global name without a `global` statement is a deliberate compile error (would shadow the BPF global)", level = "ir"}
43
+
44
+
"failing_tests/globals_parameter_and_global.py" = {reason = "A parameter may not be declared global (Python: name is parameter and global)", level = "ir"}
0 commit comments