infer icon indicating copy to clipboard operation
infer copied to clipboard

Support __nullable arguments in Objective-C blocks

Open rist opened this issue 11 years ago • 8 comments

When compiling my project I get lots of errors like these:

In file included from /Users/../SomeClass.m:12:
/Users/../SomeOtherClass.h:32:55: error: expected ')'
- (void)someMethod:(void (^)(NSError* __nullable error))block;
                                                      ^
/Users/../SomeOtherClass.h:32:34: note: to match this '('
- (void)someMethod:(void (^)(NSError* __nullable error))block;

See https://developer.apple.com/swift/blog/?id=25 for more about the __nullable

rist avatar Jun 11 '15 17:06 rist

Thanks @rist for reporting this issue! We are currently investigating it, the problem should be fixed soon.

martinoluca avatar Jun 12 '15 09:06 martinoluca

Also getting this in @property attributes and return types, like:

warning: unknown warning option '-Wno-nullable-to-nonnull-conversion'; did you mean '-Wno-non-literal-null-conversion'? [-Wunknown-warning-option]
@property (nonatomic, copy, nullable) NSString *s;
                            ^
error: expected ')'
- (UIViewController * __nullable)XXVC;
                      ^
note: to match this '('
- (UIViewController * __nullable) XXVC;
  ^

loufranco avatar Jun 18 '15 12:06 loufranco

Note also that within method declarations the nullable is not expected and thus infer fails as with an expected type error.

In file included from AppNavigation.m:9:
AppNavigation.h:19:4: error: expected a type
+ (nullable UIViewController *)getTopViewController;
   ^
AppNavigation.h:20:4: error: expected a type
+ (nullable ViewController *)getChatViewIfTopViewController; // Get any ViewController on Top
   ^
AppNavigation.h:21:4: error: expected a type
+ (nullable ViewController *)getViewController;      // Get the ViewController with Bot
   ^
3 errors generated.
Command /Downloads/infer-osx-v0.1.1/infer/infer/bin/../lib/capture/clang failed with exit code 1

sk- avatar Jun 18 '15 14:06 sk-

Yep, hitting the same issues with properties and method declarations.

matt-oakes avatar Jun 19 '15 08:06 matt-oakes

We believe the issue has been fixed in master (e17308f4d57d0b867f777785bc67424b6efeebb7). The fix will make it into the next release of Infer later this week.

jvillard avatar Jun 22 '15 13:06 jvillard

I compiled from master and this now works as expected. Thanks!

matt-oakes avatar Jun 22 '15 16:06 matt-oakes

I'm seeing the same issue for nonnull. Not sure if the fix in e17308f addresses?

altyus avatar Jun 23 '15 20:06 altyus

@altyus: yes, the patched version of clang we use now supports __nullable, __nonnull and __null_unspecified.

jvillard avatar Jun 24 '15 10:06 jvillard