musictheory / NilScript

Objective-C-style language superset of JavaScript with a tiny, simple runtime
Other
50 stars 5 forks source link

`@property` inside of `@protocol` causes infinite loop #88

Closed iccir closed 8 years ago

iccir commented 8 years ago

When porting SwiffCore, the following code (still in Obj-C) caused the parser to hang forever:

@protocol SwiffDefinition <NSObject>

- (void) clearWeakReferences;

@property (nonatomic, weak, readonly) SwiffMovie *movie;

@property (nonatomic, assign, readonly) UInt16 libraryID;
@property (nonatomic, assign, readonly) CGRect bounds;
@property (nonatomic, assign, readonly) CGRect renderBounds;

@optional
+ (Class) placedObjectClass; // If not present, defaults to SwiffPlacedObject
@end
iccir commented 8 years ago

It's not @property per-se, it's that we only lex() tokens that are @required, @optional, +, -, and @end. sourceElement is never reset to falsy, so the loop in oj_parseProtocolDefinitionBody continues forever.