Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
March 11, 2011 [Issue 5730] New: Error: variable has scoped destruction, cannot build closure | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5730 Summary: Error: variable has scoped destruction, cannot build closure Product: D Version: D2 Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: samukha@voliacable.com --- Comment #0 from Max Samukha <samukha@voliacable.com> 2011-03-11 10:22:17 PST --- The below should compile without errors: struct S { ~this() { } } void main() { S s; enum error = __traits(compiles, { auto s1 = s; })); static assert(!error); // line 1 } ---- Error: static assert (!true) is false Comment out "line 1" to get the error that explains the problem: Error: variable test.main.s has scoped destruction, cannot build closure -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 12, 2011 [Issue 5730] Error: variable has scoped destruction, cannot build closure | ||||
---|---|---|---|---|
| ||||
Posted in reply to Max Samukha | http://d.puremagic.com/issues/show_bug.cgi?id=5730 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla@digitalmars.com Resolution| |INVALID --- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2011-03-12 00:50:04 PST --- Right. {auto s1=s;} is a delegate literal. Delegate literals need to be able to survive the end of the function they are defined inside. Since s is destroyed upon the exit from main(), then this will not work, hence the error message. This is expected behavior, not a bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 12, 2011 [Issue 5730] Error: variable has scoped destruction, cannot build closure | ||||
---|---|---|---|---|
| ||||
Posted in reply to Max Samukha | http://d.puremagic.com/issues/show_bug.cgi?id=5730 --- Comment #2 from Max Samukha <samukha@voliacable.com> 2011-03-12 01:53:09 PST --- No, no. The bug is not about the impossibility to build a closure. It is about __traits(compiles) not handling the compilation error properly. It should suppress the error and evaluate to false. Another example: struct S { ~this() { } } void main() { S s; static if (__traits(compiles, { auto s1 = s; })) pragma(msg, "Can build closure"); else pragma(msg, "Cannot build closure"); } ---- The compiler outputs: Can build closure Error: variable test.main.s has scoped destruction, cannot build closure Instead, the above should compile successfully, printing "Cannot build closure" at compile time. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 12, 2011 [Issue 5730] Error: variable has scoped destruction, cannot build closure | ||||
---|---|---|---|---|
| ||||
Posted in reply to Max Samukha | http://d.puremagic.com/issues/show_bug.cgi?id=5730 Max Samukha <samukha@voliacable.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|INVALID | -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 12, 2011 [Issue 5730] __traits(compiles) does not handle "variable has scoped destruction, cannot build closure" error correctly | ||||
---|---|---|---|---|
| ||||
Posted in reply to Max Samukha | http://d.puremagic.com/issues/show_bug.cgi?id=5730 Max Samukha <samukha@voliacable.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Error: variable has scoped |__traits(compiles) does not |destruction, cannot build |handle "variable has scoped |closure |destruction, cannot build | |closure" error correctly --- Comment #3 from Max Samukha <samukha@voliacable.com> 2011-03-12 02:37:00 PST --- Changed the title -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 12, 2011 [Issue 5730] __traits(compiles) does not handle "variable has scoped destruction, cannot build closure" error correctly | ||||
---|---|---|---|---|
| ||||
Posted in reply to Max Samukha | http://d.puremagic.com/issues/show_bug.cgi?id=5730 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug@yahoo.com.au --- Comment #4 from Don <clugdbug@yahoo.com.au> 2011-03-12 11:48:11 PST --- This is happening because the "has scoped destruction" error is generated in the glue layer, not in the front-end. The same issue applies to any error message generated in e2ir.c, toir.c, or s2ir.c. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation