Whole file
terryyin/lizard
The author described this change as “Fix error function statistic in some scenario”. It counts as a record because the checks below fail on the code as it stood at 09a677e73 and pass on 3d993e1fc, with nothing else changed between the two runs.
Projectterryyin/lizard
Fix saved2022-04-14
Sharing licenceMIT · LICENSE.txt
Change size+7 −2
What the code was meant to do, written into the code itself as a save note
Fix error function statistic in some scenario
The change
| 21 | 21 | def _function_name(self, token): | |
| 22 | 22 | if token != '`': | |
| 23 | 23 | if token == '(': | |
| 24 | - | return self.next(self._member_function, token) | |
| 24 | + | if len(self.context.stacked_functions) > 0\ | |
| 25 | + | and self.context.stacked_functions[-1].name != '*global*': | |
| 26 | + | return self.next(self._function_dec, token) | |
| 27 | + | else: | |
| 28 | + | return self.next(self._member_function, token) | |
| 25 | 29 | if token == '{': | |
| 26 | 30 | return self.next(self._expect_function_impl, token) | |
| 27 | 31 | self.context.add_to_function_name(token) | |
| ⋯ | |||
| 49 | 53 | self.context.parameter(token) | |
| 50 | 54 | ||
| 51 | 55 | def _expect_function_impl(self, token): | |
| 52 | - | self.next_if(self._function_impl, token, '{') | |
| 56 | + | if token == '{' and self.last_token != 'interface': | |
| 57 | + | self.next(self._function_impl, token) | |
| 53 | 58 | ||
| 54 | 59 | def _function_impl(self, _): | |
| 55 | 60 | def callback(): | |
The check that tells the two apart
fail→pass·test/test_languages/testGo.py::Test_parser_for_Go::test_nest_function
fail→pass·test/test_languages/testGo.py::Test_parser_for_Go::test_one_function_with_return_empty_interface
Check file test/test_languages/testGo.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it09a677e732067daaa0cd3a89ffc26885cd86974e
Broken version dated2022-04-04
Modulelizard_languages.golike
Units changedGoLikeStates
Fingerprintd0917c3568a099cf
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in terryyin/lizard
- 2026-08-08fix(java): do not report control structures as methods
- 2026-07-02HalsteadClassifier
- 2026-07-02fix(csv): emit columns for extensions with multiple FUNCTION_INFO fields
- 2026-06-15fix(golike): register generic functions with [...] type params
- 2026-06-15fix(java): enhance parsing of generic and qualified type names in anonymous classes
- 2026-06-11fix(script): stop a '#' comment continuing past a trailing backslash (#317)