www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1133] New: Header generation omits parathesis

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

           Summary: Header generation omits parathesis
           Product: D
           Version: 1.011
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: benoit tionex.de


(1) does not compile

in the second example, all paranthesis for the static if are missing.
With (2) the problem starts.

========================================
= D code:
========================================
    public synchronized bool contains( dejavu.lang.JObject.JObject value ){
        return (( value in mData ) !is null );
    }
========================================
= Generated Header Code:
========================================
    bool containsKey(JObject key)
{
return key in mData !is null; //(1)
}

========================================
= D code:
========================================
T jarraycast(T, U )( U u ) {
    // elem -> []
    static if( isArrayArrayType!(T) ){
        static if( isArrayArrayType!(U) ){
            //pragma( msg, "[][]->[][] jarraycast!( " ~ demangleType!(
T.mangleof ) ~ ", " ~ demangleType!( U.mangleof ) ~ ")" );
            static assert( false );
        }
        else static if( isArrayType!(U) ){
            //pragma( msg, "[]->[][] jarraycast!( " ~ demangleType!( T.mangleof
) ~ ", " ~ demangleType!( U.mangleof ) ~ ")" );
            static assert( false );
        }
        else static if( is( U : JObject )){
            //pragma( msg, "obj->[][] jarraycast!( " ~ demangleType!(
T.mangleof ) ~ ", " ~ demangleType!( U.mangleof ) ~ ")" );
            static assert( false );
        }
        else {
            //pragma( msg, "err1: jarraycast!( " ~ demangleType!( T.mangleof )
~ ", " ~ demangleType!( U.mangleof ) ~ ")" );
            static assert( false );
        }
    }
    else static if( isArrayType!(T) ){
        static if( isArrayArrayType!(U) ){
            ////pragma( msg, "[][]->[] jarraycast!( " ~ demangleType!(
T.mangleof ) ~ ", " ~ demangleType!( U.mangleof ) ~ ")" );
            alias ElemType!(T) TE;
            alias ElemType!(U) UE;
            T res;
            res.length = u.length;
            for( int i = 0; i < u.length; i++ ){
                res[i] = jarraycast!(TE,UE)(u[i]);
            }
            return res;
        }
        else static if( isArrayType!(U) ){
            ////pragma( msg, "[]->[] jarraycast!( " ~ demangleType!( T.mangleof
) ~ ", " ~ demangleType!( U.mangleof ) ~ ")" );
            alias ElemType!(T) TE;
            return arraycast!(TE)(u);
        }
        else static if( is( U : JObject )){
            //pragma( msg, "obj->[] jarraycast!( " ~ demangleType!( T.mangleof
) ~ ", " ~ demangleType!( U.mangleof ) ~ ")" );
            JArrayT!(T) uarr = cast( JArrayT!(T) ) u;
            if( uarr is null ){
                return null;
            }
            else{
                return uarr.toArray();
            }
        }
        else {
            //pragma( msg, "err2: jarraycast!( " ~ demangleType!( T.mangleof )
~ ", " ~ demangleType!( U.mangleof ) ~ ")" );
            static assert( false );
        }
    }
    else static if( is( T : JObject )){
        static if( isArrayType!(U) ){
            //pragma( msg, "[]->obj jarraycast!( " ~ demangleType!( T.mangleof
) ~ ", " ~ demangleType!( U.mangleof ) ~ ")" );
            return JArrayT!(U).create( u );
        }
        else static if( is( U : JObject )){
            //pragma( msg, "obj->obj jarraycast!( " ~ demangleType!( T.mangleof
) ~ ", " ~ demangleType!( U.mangleof ) ~ ")" );
            static assert( false );
        }
        else {
            //pragma( msg, "err3: jarraycast!( " ~ demangleType!( T.mangleof )
~ ", " ~ demangleType!( U.mangleof ) ~ ")" );
            static assert( false );
        }
    }
    else {
        //pragma( msg, "err4: jarraycast!( " ~ demangleType!( T.mangleof ) ~ ",
" ~ demangleType!( U.mangleof ) ~ ")" );
        static assert( false );
    }
    //return null;
}

========================================
= Generated Header Code:
========================================
template jarraycast(T,U)
{
T jarraycast(U u)
{
static if(isArrayArrayType!(T))
static if(isArrayArrayType!(U))
static assert(false);
else
static if(isArrayType!(U))
static assert(false);
else
static if(is(U : JObject))
static assert(false);
else
static assert(false);



else
static if(isArrayType!(T))
static if(isArrayArrayType!(U)) //(2)
alias ElemType!(T) TE;
alias ElemType!(U) UE;
T res;
res.length = u.length;
{
for (int i = 0;
 i < u.length; i++)
{
{
res[i] = jarraycast!(TE,UE)(u[i]);
}
}
}
return res;
else
static if(isArrayType!(U))
alias ElemType!(T) TE;
return arraycast!(TE)(u);
else
static if(is(U : JObject))
JArrayT!(T) uarr = cast(JArrayT!(T))u;
if (uarr is null)
{
return null;
}
else
{
return uarr.toArray();
}
else
static assert(false);



else
static if(is(T : JObject))
static if(isArrayType!(U))
return JArrayT!(U).create(u);
else
static if(is(U : JObject))
static assert(false);
else
static assert(false);


else
static assert(false);



}
}

========================================


-- 
Apr 12 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1133





------- Comment #1 from baryluk mpi.int.pl  2007-05-24 17:10 -------
They are also omited after version:


.d

version(id) { x; y; } else { z; h; }

.di

version(id) x; y; else { z; h; }


-- 
May 24 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1133





------- Comment #2 from dprogramming myronalexander.com  2007-06-12 15:06
-------
I can confirm that the static ifs are still losing the braces in DMD 1.015.


-- 
Jun 12 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1133


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com
            Summary|Header generation omits     |Header generation omits
                   |parathesis                  |parentheses




------- Comment #3 from smjg iname.com  2007-09-29 07:44 -------
What exactly is this header generation to which you refer?


-- 
Sep 29 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1133





------- Comment #4 from benoit tionex.de  2007-09-29 08:13 -------
(In reply to comment #3)
 What exactly is this header generation to which you refer?
 

"dmd -H" --
Sep 29 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1133





------- Comment #5 from smjg iname.com  2007-09-29 08:24 -------
Oh yes.  But it's puzzling me that, in the first example, the generated header
code seems to bear little relation to the original code.


-- 
Sep 29 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1133





------- Comment #6 from benoit tionex.de  2007-09-29 08:32 -------
(In reply to comment #5)
 Oh yes.  But it's puzzling me that, in the first example, the generated header
 code seems to bear little relation to the original code.
 

yes, i probably hand edited the code to cut out unrelevant info. So the value was renamed to key. Nevertheless it shows that the necessary braces are missing. --
Sep 29 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1133





------- Comment #7 from baryluk smp.if.uj.edu.pl  2009-03-07 05:08 -------
1.039 works correctly for first example. Second is not reproductible, next time
send full examples.


# cat d1133.d
class A {
        Object[Object] mData;

    public synchronized bool contains( Object value ){
            return (( value in mData ) !is null );
    }
}
# dmd-1.039 d1133.d -c -H
# cat d1133.di
// D import file generated from 'd1.d'
class A
{
    Object[Object] mData;
    public
{
    synchronized
{
    bool contains(Object value)
{
return (value in mData) !is null;
}
}
}
}

# dmd-2.026  -c -H d1133.d
# cat d1133.di 
// D import file generated from 'd1.d'
class A
{
    Object[Object] mData;
    public
{
    synchronized
{
    bool contains(Object value)
{
return (value in mData) !is null;
}
}
}
}


-- 
Mar 07 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1133


Don <clugdbug yahoo.com.au> changed:

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


--- Comment #8 from Don <clugdbug yahoo.com.au> 2009-10-28 05:18:12 PDT ---
This was fixed in 1.037, 1.038, or 1.039.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 28 2009