www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Inconsistency with 'throw' between in, out and invariant contracts

reply Dave <Dave_member pathlink.com> writes:
DMD v0.112, GDC v0.10, Windows, Linux.

Not sure what this would be classified as (really a bug?), but invariants allow
exceptions to be thrown explicitly while in and out contracts do not.

The compiler flags any throw statements in in{} or out{} contracts as an error
with the message: "Throw statements cannot be in contracts", but allows them in
class invariant contracts.

- Dave
Feb 11 2005
next sibling parent reply =?UTF-8?B?VGhvbWFzIEvDvGhuZQ==?= writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dave wrote:

| DMD v0.112, GDC v0.10, Windows, Linux.
|
| Not sure what this would be classified as (really a bug?), but
| invariants allow exceptions to be thrown explicitly while in and out
| contracts do not.
|
| The compiler flags any throw statements in in{} or out{} contracts as
| an error with the message: "Throw statements cannot be in contracts",
| but allows them in class invariant contracts.

I'm not sure about disallowing throw in "in" and "out" contracts.

In fact "assert(0);" is a conditional throw and allowed in those contracts.

Thomas

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)

iD8DBQFCDTxO3w+/yD4P9tIRAnC7AJ9YPIotdVbN5B9ugcTOKeL4+cMtcgCeIH0m
t5qc1J88yTDwq/H9yLRpYfU=
=xZ21
-----END PGP SIGNATURE-----
Feb 11 2005
parent Dave <Dave_member pathlink.com> writes:
In article <cujja6$5ri$2 digitaldaemon.com>, =?UTF-8?B?VGhvbWFzIEvDvGhuZQ==?=
says...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dave wrote:

| DMD v0.112, GDC v0.10, Windows, Linux.
|
| Not sure what this would be classified as (really a bug?), but
| invariants allow exceptions to be thrown explicitly while in and out
| contracts do not.
|
| The compiler flags any throw statements in in{} or out{} contracts as
| an error with the message: "Throw statements cannot be in contracts",
| but allows them in class invariant contracts.

I'm not sure about disallowing throw in "in" and "out" contracts.

In fact "assert(0);" is a conditional throw and allowed in those contracts.
Yea - that's the other strange part of it.. Removing this prohibition is an oversight maybe? - Dave
Thomas

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)

iD8DBQFCDTxO3w+/yD4P9tIRAnC7AJ9YPIotdVbN5B9ugcTOKeL4+cMtcgCeIH0m
t5qc1J88yTDwq/H9yLRpYfU=
=xZ21
-----END PGP SIGNATURE-----
Feb 12 2005
prev sibling parent Vathix <vathix dprogramming.com> writes:
On Fri, 11 Feb 2005 22:48:07 +0000 (UTC), Dave <Dave_member pathlink.com>  
wrote:

 DMD v0.112, GDC v0.10, Windows, Linux.

 Not sure what this would be classified as (really a bug?), but  
 invariants allow
 exceptions to be thrown explicitly while in and out contracts do not.

 The compiler flags any throw statements in in{} or out{} contracts as an  
 error
 with the message: "Throw statements cannot be in contracts", but allows  
 them in
 class invariant contracts.

 - Dave
I complained about this a long time ago and Walter said something like he saw no reason why you can't throw in contracts. I thought it meant he'd lift the restriction.
Feb 11 2005