Commit bfe5024
authored
[mypyc] Fix crash on multiple nested decorated functions with same name (#20666)
This happens when a nested function has different definitions in
different condition branches. mypyc currently crashes in this case when
calling `get_func_target` in `transform_decorator`
https://github.com/python/mypy/blob/master/mypyc/irbuild/function.py#L118.
The `FuncDef` objects for the definitions after the first one will have
the `original_def` attribute set. This makes `get_func_target` lookup
this original def but it doesn't find it when the original def is a
decorator because registers are only created for `FuncDef`s.
Extracting a `FuncDef` from the original decorator and looking it up
instead fixes the crash.1 parent 94a3cf6 commit bfe5024
3 files changed
Lines changed: 107 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
852 | 852 | | |
853 | 853 | | |
854 | 854 | | |
855 | | - | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
856 | 858 | | |
857 | | - | |
| 859 | + | |
858 | 860 | | |
859 | 861 | | |
860 | 862 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1809 | 1809 | | |
1810 | 1810 | | |
1811 | 1811 | | |
1812 | | - | |
| 1812 | + | |
1813 | 1813 | | |
1814 | 1814 | | |
1815 | 1815 | | |
| |||
1829 | 1829 | | |
1830 | 1830 | | |
1831 | 1831 | | |
1832 | | - | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
1833 | 1851 | | |
1834 | 1852 | | |
1835 | 1853 | | |
1836 | | - | |
| 1854 | + | |
1837 | 1855 | | |
1838 | 1856 | | |
1839 | 1857 | | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
1840 | 1866 | | |
1841 | 1867 | | |
1842 | 1868 | | |
1843 | 1869 | | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
1844 | 1873 | | |
1845 | 1874 | | |
1846 | 1875 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
157 | 213 | | |
158 | 214 | | |
159 | 215 | | |
| |||
235 | 291 | | |
236 | 292 | | |
237 | 293 | | |
238 | | - | |
239 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
240 | 297 | | |
241 | 298 | | |
242 | 299 | | |
| |||
266 | 323 | | |
267 | 324 | | |
268 | 325 | | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
269 | 338 | | |
270 | 339 | | |
271 | 340 | | |
| |||
0 commit comments