Conversation
ObjCStates had no notion of @interface / @protocol, so the tokens of a class extension -- Foo ( ) { ... } -- were indistinguishable from a C function definition and the extension was reported as a function. A method body can only appear in @implementation, so an @interface / @protocol section is now skipped up to its @EnD. Refs terryyin#305
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 617f13fee6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Signed-off-by: Eljees <3.14hell@gmail.com>
|
Following up on the 13 August change — the three
Only the last row differs: the bogus Ready whenever you have time to look. |
Refs #305 — this fixes the part of that report that is still reproducible today.
Where the report stands
Running the reporter's
.mmfile againstmaster(0b97a9a) shows most of #305 has beenfixed since 2020:
init,doSomethingWithCPPobj:anddeallocare found, and the bogusif@20-23entry is gone. One line of their output survives, though — the very first one:Lines 9-12 are the class extension with its instance-variable block:
Cause
ObjCStateshas no notion of@interface/@protocol. The tokens are['@', 'interface', 'OCCFile', '(', ')', '{', ...], which for the C-like states isindistinguishable from a function definition
OCCFile () { ... }, so a function is created.The
@interface Foo : NSObject { ... }form escapes by accident: the:knocks the machineout of
_state_functionbefore the{arrives. That is why the bug is specific to classextensions and categories —
@interface Foo ()and@interface Foo (Private).Fix
A method body can only appear in
@implementation;@interfaceand@protocolare puredeclarations. The reader now skips such a section up to its
@end, so its contents neverreach the C-like states.
Tests
New
Test_objc_interfaceintest/test_languages/testObjC.py:["init", "dealloc"]; before thechange it returned
["OCCFile", "init", "dealloc"];@protocolguard, which passed before the change too and is kept as a regression test.Following
.cursor/rules/issue.mdc, the whole suite was run before and after:python -m pytest→ 1313 passed, 7 skipped, 1 failed. The single failure,test/testFilesFilter.py::TestFilesFilter::test_gitignore_filter, is pre-existing — itfails on a clean checkout of
0b97a9aas well (checked withgit stash) and is unrelated tothis change.
pycodestyle lizard_languages/objc.pyis clean.I left the issue open rather than auto-closing it, in case you read the original report more
broadly than the output it quotes.
Prepared with AI assistance, following the workflow in
.cursor/rules/. Every claim above wasverified by running it rather than assumed.