www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2167] New: is exp doesn't return correct result

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

           Summary: is exp doesn't return correct result
           Product: D
           Version: 1.030
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: davidl 126.com


in bug:
http://d.puremagic.com/issues/show_bug.cgi?id=826
a slightly modified version as following passes the test
class Foo(T)
{ this() { unknown_identifier; } }

void bar()
{ 
    bool foobar = is( Foo!(int) ); 
    assert(foobar == false);
}
void main()
{
    bar();
}

but the comment from Thomas Kühne not:
http://dstress.kuehne.cn/compile/b/bug_e2ir_520_B.d 
this bug fails


-- 
Jun 24 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2167


clugdbug yahoo.com.au changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
            Summary|is exp doesn't return       |static assert hides template
                   |correct result              |errors





I think this *is* returning the correct result. The only issue is, that
although the template instantiation fails, no error message is printed. (just
"static assert is false"). But static assert is a bit wierd (and not terribly
useful any more), so I'm not even certain that it is a bug.


-- 
Jun 30 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2167






Let me rephrase:

class Templ(T) { this(){ unknown_identifier; } }

void main() {
    static assert(false == is(Templ!(int))); // correctly passes
}

    static assert(false == is(Templ!(int))); // fails, yet they are the same,
the only difference is a scope


-- 
Jun 30 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2167






The following one fails to compile:

class Templ(T) { this(){ unknown_identifier; } }
static assert(true == is(Templ!(int)));

with the following reason:
Error: undefined identifier unknown_identifier

And so does this:
static assert(true == __traits(compiles, Templ!(int)));

IMO, incorrect code in __traits(compiles) should not lead to compilation
errors.


-- 
Jun 30 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2167


davidl 126.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|diagnostic                  |
            Summary|static assert hides template|incorrect static assert
                   |errors                      |behavior





as Koroskin Denis rephrased, it's clearly a misbehavior.


-- 
Jul 01 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2167


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com
           Keywords|                            |rejects-valid
            Summary|incorrect static assert     |incorrect behaviour of
                   |behavior                    |IsExpression on invalid
                   |                            |template instance





The original issue isn't a bug, since the point of IsExpression is that
semantic errors never escape it - it just evaluates to false instead.

But the issue raised from comment 2 onwards is certainly a bug, and the
behaviour is quite strange.

----------
import std.stdio;
class Templ(T) { this(){ unknown_identifier; } }

void main() {
    pragma(msg, "In main: " ~ is(Templ!(int)).stringof);
}
----------
In main: 0
----------

But add this line at the very end

pragma(msg, "Global: " ~ is(Templ!(int)).stringof);
----------
Global: 1
In main: 1
bz2167a.d(2): Error: undefined identifier unknown_identifier
bz2167a.d(2): Error: identifier has no effect in expression
(unknown_identifier)
----------


-- 
Nov 24 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2167


Don <clugdbug yahoo.com.au> changed:

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



*** This issue has been marked as a duplicate of issue 965 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 21 2012