Whole file

terryyin/lizard

The author described this change as Fix func keyword usage in Golike structs and interfaces. It counts as a record because the checks below fail on the code as it stood at 7b47f8885 and pass on 214288237, with nothing else changed between the two runs.

Fix saved2024-10-07
Sharing licenceMIT · LICENSE.txt
Change size+21 0

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

Fix func keyword usage in Golike structs and interfaces

The change

1313 if token == self.FUNC_KEYWORD:
1414 self._state = self._function_name
1515 self.context.push_new_function('')
16+ elif token == 'type':
17+ self._state = self._type_definition
1618 elif token in '{':
1719 self.sub_state(self.statemachine_clone())
1820 elif token in '}':
1921 self.statemachine_return()
22+
23+ def _type_definition(self, token):
24+ self._state = self._after_type_name
25+
26+ def _after_type_name(self, token):
27+ if token == 'struct':
28+ self._state = self._struct_definition
29+ elif token == 'interface':
30+ self._state = self._interface_definition
31+ else:
32+ self._state = self._state_global
33+
34+ @CodeStateMachine.read_inside_brackets_then("{}", "_state_global")
35+ def _struct_definition(self, tokens):
36+ pass
37+
38+ @CodeStateMachine.read_inside_brackets_then("{}", "_state_global")
39+ def _interface_definition(self, tokens):
40+ pass
2041
2142 def _function_name(self, token):
2243 if token != '`':

The check that tells the two apart

failpass·test/test_languages/testGo.py::Test_parser_for_Go::test_interface_with_func_followed_by_function_with_receiver
failpass·test/test_languages/testGo.py::Test_parser_for_Go::test_struct_with_func_followed_by_function_with_receiver

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 it7b47f8885eb694e6ec82df21e024f2b5265ffba9
Broken version dated2024-04-25
Modulelizard_languages.golike
Units changedGoLikeStates
Fingerprint765b0cb7f166f834
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