Whole file

terryyin/lizard

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

Fix saved2025-02-04
Sharing licenceMIT · LICENSE.txt
Change size+23 0

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

fix: https://github.com/terryyin/lizard/issues/296

The change

1717 super(GoReader, self).__init__(context)
1818 self.parallel_states = [GoStates(context)]
1919
20+ @staticmethod
21+ def generate_tokens(source_code, addition='', token_class=None):
22+ addition = addition + r"|`[^`]*`" # Add support for backtick-quoted strings
23+ return CodeReader.generate_tokens(source_code, addition, token_class)
24+
25+ def __call__(self, tokens, reader):
26+ self.context = reader.context
27+ for token in tokens:
28+ # Skip counting ? in backtick-quoted strings
29+ if token.startswith('`') and token.endswith('`'):
30+ for state in self.parallel_states:
31+ state(token)
32+ yield token
33+ continue
34+
35+ # For non-backtick tokens, process normally
36+ for state in self.parallel_states:
37+ state(token)
38+ yield token
39+ for state in self.parallel_states:
40+ state.statemachine_before_return()
41+ self.eof()
42+
2043
2144 class GoStates(GoLikeStates): # pylint: disable=R0903
2245 pass

The check that tells the two apart

failpass·test/test_languages/testGo.py::Test_parser_for_Go::test_sql_query_with_question_marks

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 itfed797ce7095c73a6d1f8ac0b609e2f314fda85f
Broken version dated2025-02-04
Modulelizard_languages.go
Units changedGoReader
Fingerprinted39445e85ddf067
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