[Issue 8788] The super constructor call can be prevented by mentioning "return".

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Oct 10 03:22:56 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8788


Don <clugdbug at yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug at yahoo.com.au


--- Comment #2 from Don <clugdbug at yahoo.com.au> 2012-10-10 02:58:34 PDT ---
statement.c, ReturnStatement::semantic() contains this comment:

   /* BUG: need to issue an error on:
     *  this
     *  {   if (x) return;
     *      super();
     *  }
     */
Funny that this never got entered in Bugzilla before. The bug however is in the
treatment of CSXreturn, mainly in scope.c.

For each branch of code there are 5 cases:
1. neither constructor calls nor returns have been made.
2. at least one subbranch has returned without calling a constructor.
3. all subbranches have called a constructor. Some may have returned
afterwards, but at least one has not returned yet.
4. all subbranches have exited after calling a constructor
5. some subbranches have returned after calling a constructor, the others have
not yet made constructor calls.


The case with the 'throw' is more difficult than the others. Ideally the first
example below would be OK but the second would be an error:

  try {
    thow SomeFunkyException;
  }
  catch (SomeFunkyException) {
      super();
  }

  try {
    thow SomeFunkyException;
  }
  catch (DifferentFunkyException) {
      super();
  }
It might be worth forbidding 'super()' inside catch clauses.

I don't think it's worth the effort. But the 'return' cases should be detected.

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


More information about the Digitalmars-d-bugs mailing list