new version; this one requires 'parser code cleanup' from 11070
text/plain
4504
Comments
Comment #0 by andre — 2014-09-24T14:37:39Z
Currently this code is not accepted:
with (auto p = new Panel())
{
parent = this;
text = "bla";
with (new Button())
{
parent = p; // Here p is needed
text = "bla2";
}
}
auto is not allowed in with statement. p is needed as parent attribute
of the new button.
One workaround would be to change the coding to:
Panel p;
with (p = new Panel()) {...}
While this coding is working, it seems like a missing feature auto
is not working.
Could you check?
In the discussion http://forum.dlang.org/thread/[email protected]
also someone mentioned auto would make sense in switch,
but can't judge on that.
Comment #1 by ketmar — 2014-09-24T23:40:08Z
Created attachment 1432
preliminary realization
this is quick-and-dirty patch that allows declarations in with(). hdrgen emits fixed .di files too.
please note that this is my first patch outside of parser scope and i'm not sure what i'm doing here. it seems to work on simple test cases (see second attachement) but it need to be reviewed by someone who knows compiler internals.
so far the patch seems to not breaking existing code, so it can be safely tested.
Comment #2 by ketmar — 2014-09-24T23:40:52Z
Created attachment 1433
simple testcase
Comment #3 by ketmar — 2014-09-27T01:38:35Z
Created attachment 1437
new version; this one requires 'parser code cleanup' from 11070
Comment #4 by ketmar — 2015-03-22T02:49:53Z
*** Issue 14316 has been marked as a duplicate of this issue. ***
Comment #5 by ketmar — 2016-06-09T07:01:02Z
*** Issue 16140 has been marked as a duplicate of this issue. ***
Comment #6 by robert.schadek — 2024-12-13T18:29:22Z