Bug 8704 – Invalid nested struct constructions should be detected

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-09-21T07:03:00Z
Last change time
2014-05-14T12:11:40Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
k.hara.pg

Comments

Comment #0 by k.hara.pg — 2012-09-21T07:03:47Z
By fixing issue 8339, invalid accessing to nested struct shows compile error. But, some cases are still accidentally accepted. void check(T)() { // nested struct constructions outside valid frame scope T t1 = T(); T t2 = T(1); } void main() { struct S { int n; void foo(){} } check!S(); }
Comment #1 by k.hara.pg — 2012-09-21T07:08:49Z
Comment #2 by andrej.mitrovich — 2012-09-21T08:25:16Z
What exact rules does the language define for these function-nested types? It seems arbitrary that some things are allowed while others are not, for example this works: void check(T)() { T t = T.init; t.foo(); } void main() { struct S { int n; void foo(){} } check!S(); }
Comment #3 by yebblies — 2013-11-24T06:03:57Z
The pull request wasn't merged, but both cases now error.
Comment #4 by k.hara.pg — 2014-04-11T12:14:25Z
(In reply to yebblies from comment #3) > The pull request wasn't merged, but both cases now error. The opening test case still does not cause front-end errors (no error occur with -o- switch). And T t; should also be rejected if T is nested struct. Updated test case is: void check(T)() { // nested struct constructions outside valid frame scope T t0; // new! T t1 = T(); T t2 = T(1); } void main() { struct S { int n; void foo(){} } check!S(); } (In reply to Kenji Hara from comment #1) > https://github.com/D-Programming-Language/dmd/pull/1133 I reopened the pull request to fix this issue perfectly.
Comment #5 by k.hara.pg — 2014-04-11T12:18:35Z
*** Issue 5902 has been marked as a duplicate of this issue. ***
Comment #6 by github-bugzilla — 2014-05-14T12:11:39Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/da0be7592a903af33da5d65792e38e265f560bb3 fix Issue 8704 - Invalid nested struct constructions should be detected https://github.com/D-Programming-Language/dmd/commit/3232f56a34900bd4228c22134b637464bb37ed0c Merge pull request #1133 from 9rnsr/fix8704 Issue 8704 - Invalid nested struct constructions should be detected