Whole file

terryyin/lizard

The author described this change as fix(objc): handle nested parens in block / function-pointer param types. It counts as a record because the checks below fail on the code as it stood at 06284ec87 and pass on 6001e5462, with nothing else changed between the two runs.

Fix saved2026-06-02
Sharing licenceMIT · LICENSE.txt
Change size+15 2

What the code was meant to do, written into the code itself as a save note

fix(objc): handle nested parens in block / function-pointer param types

The change

2323
2424
2525 class ObjCStates(CLikeStates): # pylint: disable=R0903
26+ def __init__(self, context):
27+ super(ObjCStates, self).__init__(context)
28+ self._objc_param_paren_depth = 0
29+
2630 def _state_global(self, token):
2731 super(ObjCStates, self)._state_global(token)
2832 if token == 'typedef':
5054
5155 def _state_objc_dec(self, token):
5256 if token == '(':
57+ self._objc_param_paren_depth = 0
5358 self._state = self._state_objc_param_type
5459 self.context.add_to_long_function_name(token)
5560 elif token == ',':
6166 self.context.add_to_function_name(" " + token)
6267
6368 def _state_objc_param_type(self, token):
64- if token == ')':
65- self._state = self._state_objc_param
69+ # A block / function-pointer param type, e.g. (void (^)(int)), nests
70+ # parentheses; balance them so the type ends at its matching ')'
71+ # rather than the first inner one (issue #365).
72+ if token == '(':
73+ self._objc_param_paren_depth += 1
74+ elif token == ')':
75+ if self._objc_param_paren_depth > 0:
76+ self._objc_param_paren_depth -= 1
77+ else:
78+ self._state = self._state_objc_param
6679 self.context.add_to_long_function_name(" " + token)
6780
6881 def _state_objc_param(self, _):

The check that tells the two apart

failpass·test/test_languages/testObjC.py::Test_objc_lizard::test_objc_method_with_block_param
failpass·test/test_languages/testObjC.py::Test_objc_lizard::test_objc_method_with_function_pointer_param

Check file test/test_languages/testObjC.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 it06284ec87c1966fee4ddbf3f068ccf89b987b0f8
Broken version dated2026-06-02
Modulelizard_languages.objc
Units changedObjCStates
Fingerprint662c4f60a7f94357
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