bugGNUstep - Bugs: bug #47618, NSPredicate: SELF implemented...

 
 

You are not allowed to post comments on this tracker with your current authentification level.

bug #47618: NSPredicate: SELF implemented incorrectly

Submitted by:  Niels Grewe <thebeing>
Submitted on:  Mon Apr 4 14:56:49 2016  
 
Category: Base/FoundationSeverity: 3 - Normal
Item Group: BugStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Open

Mon Apr 4 14:56:49 2016, original submission:

The SELF expression in NSPredicate is implemented in a way that only allows it to be used as LHS or RHS expression in an NSComparison predicate.

In particular, the following is legal under Cocoa:

NSDictionary *a = [NSDictionary dictionaryWithObjectsAndKeys:
@"2", @"foo", nil];
NSPredicate *p = [NSPredicate predicateWithFormat: @"SELF.foo <= 2"];
[p evaluateWithObject: a];

The base implementation gives you:

Uncaught exception NSInvalidArgumentException, reason: [GSEvaluatedObjectExpression-keyPath] should be overridden by subclass

You can even do more complicated expressions such as "bar[SELF.foo]", where SELF is not a top-level expression in Cocoa.

The reason is that GSEvaluatedObjectExpression is created as a singleton, and always returns itself from expressionValueWithObject:context:, and there is some pointer equality checking in NSComparisonPredicate to make it work for the really simple case (self == 'foo'). That totally sounds like premature optimisation to me, btw.

Niels Grewe <thebeing>
Project Member

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by thebeing (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    No Changes Have Been Made to This Item

    Back to the top


    Powered by Savane 3.1-cleanup1