github / stack-graphs

Rust implementation of stack graphs
https://docs.rs/stack-graphs/*/stack_graphs/
Apache License 2.0
717 stars 122 forks source link

fix/python nested function declaration #434

Closed nohehf closed 1 month ago

nohehf commented 1 month ago

This fixes #404. The problem was that the stanza targeted every function first param, not only methods. As:

let @body.class_self_scope = #null
let @body.class_member_attr_scope = #null

Was run for each function, nested function would try to create an edge to a null value:

  edge @param.def -> @first_param.class_self_scope
  edge @param.class_member_attr_scope -> @first_param.output

I actually think there might be an issue with TSG itself, as class_self_scope and class_member_attr_scope are inherited, setting those to null for the function scope should fallback to a higher parent. I might investigate on this.