www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2955] New: Compiler rejects chained <>=

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2955

           Summary: Compiler rejects chained <>=
           Product: D
           Version: 1.041
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: lijat.me gmail.com


The following code

void main(){
        double a,b,c;
        assert(a <>= b <>= c);
}

gets this response from the compiler

johang klaffhorn:~$ dmd test.d 
test.d(4): found '<>=' when expecting ')'
test.d(4): found 'c' when expecting ';' following 'statement'
test.d(4): found ')' instead of statement
johang klaffhorn:~$

if parenthesis are added the problem disappear.

If this is not valid code the a more helpful error message would be nice.


-- 
May 09 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2955


jarrett.billingsley gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




------- Comment #1 from jarrett.billingsley gmail.com  2009-05-09 10:31 -------
This is by design.  Comparison operators cannot be chained like this.  C
accepts such foolishness as "a < b < c" even though it doesn't do what you'd
expect (i.e. it doesn't evaluate to "a < b && b < c").  D changed all
comparison operators to have the same precedence so that this kind of code
would not be accepted, and for possible future expansion in which chained
comparisons really would be converted into multiple clauses.


-- 
May 09 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2955





------- Comment #2 from lijat.me gmail.com  2009-05-09 20:05 -------
In that case I think that a better error message would be needed. The current
one left me confused about if it was a compiler bug or by design.


-- 
May 09 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2955


jarrett.billingsley gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |




------- Comment #3 from jarrett.billingsley gmail.com  2009-05-09 20:46 -------
Fair enough :)


-- 
May 09 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2955


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
                 CC|                            |andrei metalanguage.com
         Resolution|                            |WONTFIX


--- Comment #4 from Andrei Alexandrescu <andrei metalanguage.com> 2011-01-08
16:17:12 PST ---
I think we're good as we are.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 08 2011