Thread overview
Inconsistency with 'throw' between in, out and invariant contracts
Feb 11, 2005
Dave
Feb 12, 2005
Thomas Kühne
Feb 12, 2005
Dave
Feb 12, 2005
Vathix
February 11, 2005
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


February 12, 2005
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

February 12, 2005
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.
February 12, 2005
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-----