bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #47618] NSPredicate: SELF implemented incorrectly


From: Niels Grewe
Subject: [bug #47618] NSPredicate: SELF implemented incorrectly
Date: Mon, 04 Apr 2016 14:56:51 +0000
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/601.5.17 (KHTML, like Gecko) Version/9.1 Safari/601.5.17

URL:
  <http://savannah.gnu.org/bugs/?47618>

                 Summary: NSPredicate: SELF implemented incorrectly
                 Project: GNUstep
            Submitted by: thebeing
            Submitted on: Mo 04 Apr 2016 14:56:49 GMT
                Category: Base/Foundation
                Severity: 3 - Normal
              Item Group: Bug
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

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.





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?47618>

_______________________________________________
  Nachricht gesendet von/durch Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]