www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7482] New: deprecation isn't checked inside forward referenced is(typeof())

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

           Summary: deprecation isn't checked inside forward referenced
                    is(typeof())
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: clugdbug yahoo.com.au



static if (is(typeof(Z))) {} else {static assert(0, "first time");}

deprecated int Z;

static if (is(typeof(Z))) {} else {static assert(0, "second time lucky");}
----------
crash.d(5): Error: static assert  "second time lucky"
It should assert the first time.

This is another gagging bug, related to bug 4269, but the problem isn't an
invalid type. Here, the first typeof doesn't check deprecation.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 10 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7482


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |spec
                 CC|                            |smjg iname.com
             Blocks|                            |340



I'm not sure what's meant to happen here.  Z still exists, even if it's
deprecated.  But by deprecating it, we are basically telling the compiler to
treat it as if it doesn't exist.

This is a difficult case, because to treat deprecated stuff as nonexistent in
IsExpressions causes the program to compile and behave differently depending on
whether the compiler switch to enable deprecated features is switched on or
not.

If the correct behaviour is given anywhere in the spec, I haven't managed to
find it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 11 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7482


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com



11:25:33 PST ---
Deprecation is most definitely not about declarations not existing. It is about
being an error to reference them.

For example,

   deprecated void foo(int);
   void foo(long);

   ...
   foo(0);   // error, foo(int) is deprecated

rather than selecting foo(long), which it would if foo(int) "disappeared".

IOW, deprecation checking is done *after* symbol resolution, not before.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 12 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7482


timon.gehr gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timon.gehr gmx.ch



I think both static if conditions should fail to compile because they reference
a deprecated symbol. In other words, error gagging should not apply to
deprecation errors. It should be impossible for 'deprecated' to silently change
the behavior of a program.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 12 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7482




I've started a thread on the newsgroup about this whole topic.
"Thoughts about deprecation"
http://tinyurl.com/832hhqj

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 12 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7482


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|deprecation isn't checked   |deprecation isn't checked
                   |inside forward referenced   |inside forward referenced
                   |is(typeof())                |typeof()



 Deprecation is most definitely not about declarations not existing. It is
about being an error to reference them.
Right, but is(typeof(X)) isn't a check if X exists, even though a popular idiom is to use it for that purpose. Rather, it asks what type X has. And I think that has to be considered as referencing X, and is therefore an error. If it's not an error, it has to be able to provide a type, and that's a problem: static if (is(typeof(Z) M)) { M we_are_relying_on_a_deprecated_variable; } deprecated int Z; But it turns out that this bug has nothing to do with is(). alias typeof(Z) Q1; // compiles deprecated int Z; alias typeof(Z) Q2; // doesn't compile In fact, it seems it doesn't even require deprecated: alias typeof(Z1) Q1; pragma(msg, Q1.stringof); // int const int Z1; alias typeof(Z1) R1; pragma(msg, R1.stringof); // const(int) and yet if you write const (int) Z1; it displays const(int) in both cases. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 16 2012