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.

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

5757 self.next(self._function_dec, token)
5858 elif token == "<":
5959 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)
6065 else:
6166 self._state = self._state_global
6267
6368 @CodeStateMachine.read_inside_brackets_then("<>", "_expect_function_dec")
6469 def _generalize(self, tokens):
70+ pass
71+
72+ @CodeStateMachine.read_inside_brackets_then("[]", "_expect_function_dec")
73+ def _generalize_type_params(self, tokens):
6574 pass
6675
6776 @CodeStateMachine.read_inside_brackets_then("()", '_function_name')

The check that tells the two apart

failpass·test/test_languages/testGo.py::Test_parser_for_Go::test_generic_function_with_multiple_type_params
failpass·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