lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erick Erickson (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (SOLR-2876) Precedence operator in conditionals with ternary operator needs to be examined.
Date Fri, 04 Nov 2011 17:39:51 GMT

    [ https://issues.apache.org/jira/browse/SOLR-2876?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13144197#comment-13144197
] 

Erick Erickson commented on SOLR-2876:
--------------------------------------

Dear God! You mean the intent here is:

return (pf.filter==null && pf.postFilter==null) ? qr.getDocSet() : null;

??? gotta confess I just saw the pattern and jumped to conclusions, hadn't examined the code
at all. But you've just made the job tougher... Wait, I know! I'll just write something in
awk to convert *everything* in the source tree.

The ternary operator really annoys me for this very reason... rant, rant, rant.....
                
> Precedence operator in conditionals with ternary operator needs to be examined.
> -------------------------------------------------------------------------------
>
>                 Key: SOLR-2876
>                 URL: https://issues.apache.org/jira/browse/SOLR-2876
>             Project: Solr
>          Issue Type: Bug
>    Affects Versions: 3.5, 4.0
>         Environment: all
>            Reporter: Erick Erickson
>            Assignee: Erick Erickson
>              Labels: operator, precedence, ternary
>
> This is an offshoot of 2829 where the root of the bug was that precedence in the ternary
operator along with && without appropriate parentheses was a problem.
> && this.parser == null ? other.parser == null : this.parser.getClass() == other.parser.getClass()
(from ShortFieldSource.java).
> So that got me curious whether this pattern was repeated. A quick grep with the following
REs produced one hit I wasn't related to 2829 with && and more with || (3x code base).
I'll try to get to it over the weekend. Please don't grab it just yet, I'm fixing this partially
for 2829, but if anyone wants to try the grep and see if I'm hallucinating, I'd appreciate
it. I'd *really* appreciate any tests for things people see...
> Some of the returns are false hits, but not others. See 
> SolrIndexSearcher.getDocListAndSetNC() 
> the last line is: return pf.filter==null && pf.postFilter==null ? qr.getDocSet()
: null; 
> REs (using them in IntelliJ)
> \|\|[\sa-z\.0-9A-Z]+==.*\?
> &&[\sa-z\.0-9A-Z]+==.*\?
> I got some hits with the above and didn't pursue it any further, but if anyone wants
to suggest more comprehensive REs, please attach. I'm trying for "&& or || followed
by anything without an open parentheses followed by == followed by anything followed by ?"
I'd rather get a manageable number of false positives than miss things.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message