digitalmars.D.bugs - contracts + nested functions + derived types = poo
- Buchan (28/28) Nov 09 2004 Me again:
- Walter (4/31) Nov 11 2004 I don't know what in specific you mean, but there are several syntactica...
- Buchan (9/38) Nov 11 2004 Specificly? It compiles fine with it commented, and complains when
- Walter (4/43) Nov 11 2004 syntactical
- Thomas =?UTF-8?B?S8O8aG5l?= (9/10) Nov 11 2004 Nested functions require a full set of in&out&body whereas "normal"
- Walter (3/13) Nov 11 2004 I'll review it again and straighten it out.
-
Buchan
(33/39)
Nov 13 2004
- Thomas =?UTF-8?B?S8O8aG5l?= (6/38) Nov 14 2004 added to DStress as
- Simon Buchan (5/5) Nov 14 2004 Looking at the code, I see I accidently left my old e-mail in my account...
Me again: <code> int main(){ return foo(1); } struct a {int b;} int foo(int i) { a bar() // uncomment for error /*out (result) { // out body } body */{ a r; r.b = 1; return r; } return bar().b; } </code> you probably need to specify -debug to get it. Any derived type (structures, arrays, functions (can you return a function?)) as a return type for a nested function with any in/out/body block (even just body) causes this. -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 09 2004
I don't know what in specific you mean, but there are several syntactical errors here. "Buchan" <kbuchan xtra.co.nz> wrote in message news:opsg68fuvz44buww simon.mshome.net...Me again: <code> int main(){ return foo(1); } struct a {int b;} int foo(int i) { a bar() // uncomment for error /*out (result) { // out body } body */{ a r; r.b = 1; return r; } return bar().b; } </code> you probably need to specify -debug to get it. Any derived type (structures, arrays, functions (can you return a function?)) as a return type for a nested function with any in/out/body block (even just body) causes this. -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 11 2004
On Thu, 11 Nov 2004 01:12:01 -0800, Walter <newshound digitalmars.com> wrote:I don't know what in specific you mean, but there are several syntactical errors here. "Buchan" <kbuchan xtra.co.nz> wrote in message news:opsg68fuvz44buww simon.mshome.net...Specificly? It compiles fine with it commented, and complains when uncommented. Is there any reason that a nested function that returns a non-basic type cannot have in/out contracts? Or am I being really stupid again? -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/Me again: <code> int main(){ return foo(1); } struct a {int b;} int foo(int i) { a bar() // uncomment for error /*out (result) { // out body } body */{ a r; r.b = 1; return r; } return bar().b; } </code> <snip>
Nov 11 2004
"Buchan" <kbuchan xtra.co.nz> wrote in message news:opshaqkvgr44buww simon.mshome.net...On Thu, 11 Nov 2004 01:12:01 -0800, Walter <newshound digitalmars.com> wrote:syntacticalI don't know what in specific you mean, but there are severalYou need an in{} preceding the out{}.errors here. "Buchan" <kbuchan xtra.co.nz> wrote in message news:opsg68fuvz44buww simon.mshome.net...Me again: <code> int main(){ return foo(1); } struct a {int b;} int foo(int i) { a bar() // uncomment for errorSpecificly? It compiles fine with it commented, and complains when uncommented. Is there any reason that a nested function that returns a non-basic type cannot have in/out contracts? Or am I being really stupid again? -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2//*out (result) { // out body } body */{ a r; r.b = 1; return r; } return bar().b; } </code> <snip>
Nov 11 2004
Walter schrieb am Donnerstag, 11. November 2004 19:53:You need an in{} preceding the out{}.Nested functions require a full set of in&out&body whereas "normal" functions require one of the combinations: body, in&body, out&body or in&out&body. Is this a bug or a language feature that I missed while reading the documentation? In addition I might have missed the sequence requirements for in/out/body. e.g. out/in/body compiles, but in/body/out fails Thomas
Nov 11 2004
I'll review it again and straighten it out. "Thomas Kühne" <thomas-dloop kuehne.cn> wrote in message news:cn0llv$10u5$1 digitaldaemon.com...Walter schrieb am Donnerstag, 11. November 2004 19:53:You need an in{} preceding the out{}.Nested functions require a full set of in&out&body whereas "normal" functions require one of the combinations: body, in&body, out&body or in&out&body. Is this a bug or a language feature that I missed while reading the documentation? In addition I might have missed the sequence requirements for in/out/body. e.g. out/in/body compiles, but in/body/out fails Thomas
Nov 11 2004
On Thu, 11 Nov 2004 10:53:48 -0800, Walter <newshound digitalmars.com> wrote:"Buchan" <kbuchan xtra.co.nz> wrote in message news:opshaqkvgr44buww simon.mshome.net...<snip>On Thu, 11 Nov 2004 01:12:01 -0800, Walter <newshound digitalmars.com> wrote:You need an in{} preceding the out{}.<snip> Oh? I didnt see that in the documentation... but it does the same even with both. int main(){ return foo(); } struct a {int b;} int foo() { a bar() /* in { assert(1); } out (result) { assert(result.b); } body*/ { a r; r.b = 1; return r; } a r2 = bar(); return r2.b; } If you rewrite this to return a basic type like int, it's fine. (Of course, I've made an idiot of myself before... ;) -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 13 2004
added to DStress as http://svn.kuehne.cn/dstress/run/in_out_body_01.d ... http://svn.kuehne.cn/dstress/run/in_out_body_04.d Thomas Buchan schrieb am Sonntag, 14. November 2004 07:50:Oh? I didnt see that in the documentation... but it does the same even with both. int main(){ return foo(); } struct a {int b;} int foo() { a bar() /* in { assert(1); } out (result) { assert(result.b); } body*/ { a r; r.b = 1; return r; } a r2 = bar(); return r2.b; } If you rewrite this to return a basic type like int, it's fine. (Of course, I've made an idiot of myself before... ;)
Nov 14 2004
Looking at the code, I see I accidently left my old e-mail in my account... BTW, I really should use better names for my variables, nice clean (I think I wrote that after reading some of the DMD frontend code though ]:D) -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 14 2004