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.
Projectterryyin/lizard
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
| 17 | 17 | super(GoReader, self).__init__(context) | |
| 18 | 18 | self.parallel_states = [GoStates(context)] | |
| 19 | 19 | ||
| 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 | + | ||
| 20 | 43 | ||
| 21 | 44 | class GoStates(GoLikeStates): # pylint: disable=R0903 | |
| 22 | 45 | pass |
The check that tells the two apart
fail→pass·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
- 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(golike): register generic functions with [...] type params
- 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)