One function

CLikeNestingStackStates in terryyin/lizard

The author described this change as fix https://github.com/terryyin/lizard/issues/178. It counts as a record because the check below fails on the code as it stood at fe6cafa6f and passes on 7c294306c, with nothing else changed between the two runs.

Fix saved2017-08-22
Sharing licenceMIT · LICENSE.txt
Change size+1 1

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

Machinery to track nesting levels of tokens. The main indicators of nesting are braces: '{' and '}'. However, the code is complicated due to braceless structures, which are control-flow structures in C-like languages. Moreover, using braces as nesting level indicators leads to a big caveat; C++ initializer lists, uniform initialization, and any other constructs with braces add extra nesting level. Another complication comes from nested classes inside function bodies and control-flow declarations/bodies. The handling of these complex cases is unspecified and can be ignored.

The change

8282 self.__structure_brace_stack.append(False)
8383
8484 elif token == '}':
85- if self.__structure_brace_stack and self.__structure_brace_stack[-1]:
85+ while self.__structure_brace_stack and self.__structure_brace_stack[-1]:
8686 self.__pop_structures()
8787 self.__pop_structures()
8888 elif (token == ";" and self.__structure_brace_stack and

The check that tells the two apart

failpass·test/test_languages/testCAndCPP.py::Test_Preprocessing::test_body_with_macro_call_after_if_and_no_semicolon_before_the_closing_br2

Check file test/test_languages/testCAndCPP.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 itfe6cafa6feec1f1d2787ce609da29af51c5c1c2a
Broken version dated2017-08-21
Modulelizard_languages.clike
Units changedCLikeNestingStackStates
Fingerprint5f6d8a76d99f2243
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