digitalmars.D.bugs - [Issue 5882] New: Helper inner function in body{} and out{}
- d-bugmail puremagic.com (61/61) Apr 24 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5882
http://d.puremagic.com/issues/show_bug.cgi?id=5882
Summary: Helper inner function in body{} and out{}
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: bearophile_hugs eml.cc
Let's say I have a function foo() that uses an inner function bar(). To test
the correctness of the result of foo() I have sometimes to use bar() in foo()
post-condition too:
void foo()
in {
void bar() {}
bar();
} out {
void bar() {}
bar();
} body {
void bar() {}
bar();
}
void main() {}
But in DMD 2.052 this is not allowed:
test.d(6): Error: declaration bar is already defined in another scope in foo
test.d(9): Error: declaration bar is already defined in another scope in foo
bar() is not available inside the post-condition and pre-condition:
void foo()
in {
bar();
} out {
bar();
} body {
void bar() {}
bar();
}
void main() {}
It gives:
test.d(3): Error: undefined identifier bar
test.d(5): Error: undefined identifier bar
So currently the workaround is to define bar() again, with different names:
void foo()
in {
void bar_in() {}
bar_in();
} out {
void bar_out() {}
bar_out();
} body {
void bar() {}
bar();
}
void main() {}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 24 2011








d-bugmail puremagic.com