Whole file
terryyin/lizard
The author described this change as “fix(golike): register generic functions with [...] type params”. It counts as a record because the checks below fail on the code as it stood at 0b97a9ae8 and pass on ad7ad28bd, with nothing else changed between the two runs.
Projectterryyin/lizard
Fix saved2026-06-15
Sharing licenceMIT · LICENSE.txt
Change size+9 −0
What the code was meant to do, written into the code itself as a save note
fix(golike): register generic functions with [...] type params
The change
| 57 | 57 | self.next(self._function_dec, token) | |
| 58 | 58 | elif token == "<": | |
| 59 | 59 | self.next(self._generalize, token) | |
| 60 | + | elif token == "[": | |
| 61 | + | # Square-bracket type parameters, e.g. Scala `def f[T](x: T)` or | |
| 62 | + | # Go `func F[T any](x T)`. Skip them like the `<>` generics above | |
| 63 | + | # so the following `(` params still register the function. | |
| 64 | + | self.next(self._generalize_type_params, token) | |
| 60 | 65 | else: | |
| 61 | 66 | self._state = self._state_global | |
| 62 | 67 | ||
| 63 | 68 | @CodeStateMachine.read_inside_brackets_then("<>", "_expect_function_dec") | |
| 64 | 69 | def _generalize(self, tokens): | |
| 70 | + | pass | |
| 71 | + | ||
| 72 | + | @CodeStateMachine.read_inside_brackets_then("[]", "_expect_function_dec") | |
| 73 | + | def _generalize_type_params(self, tokens): | |
| 65 | 74 | pass | |
| 66 | 75 | ||
| 67 | 76 | @CodeStateMachine.read_inside_brackets_then("()", '_function_name') |
The check that tells the two apart
fail→pass·test/test_languages/testGo.py::Test_parser_for_Go::test_generic_function_with_multiple_type_params
fail→pass·test/test_languages/testGo.py::Test_parser_for_Go::test_generic_function_with_type_param
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 it0b97a9ae8e77b8d559e7ef187ad4b4e3ef02924f
Broken version dated2026-06-15
Modulelizard_languages.golike
Units changedGoLikeStates
Fingerprinte83112c667225c06
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(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)
- 2026-06-02fix(objc): handle nested parens in block / function-pointer param types