Bug 15650 – Closure variable access broken if only referenced in contract

Status
NEW
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-02-06T20:34:25Z
Last change time
2024-12-13T18:46:46Z
Assigned to
No Owner
Creator
David Nadlinger
Moved to GitHub: dmd#19096 →

Comments

Comment #0 by code — 2016-02-06T20:34:25Z
The following test case, an adapted version of runnable/test10981.d, fails using DMD 2.070 (OS X, but that's irrelevant): --- auto foo(int i) { class X1 { void in_nested() in { import core.stdc.stdio; printf("%d\n", i); assert(i); } body {} } return new X1; } void main() { auto a = foo(1234); a.in_nested(); } --- The problem seems to be that the frontend assumes that variable references from contracts *never* make the variable in question a closureVar, irrespective of whether the variable accessed is in the direct parent function or further up the chain. [1] https://github.com/D-Programming-Language/dmd/blob/9d1edd1e78031e5760cc7cf923dd0bf9b1f8e7e6/src/declaration.d#L2232
Comment #1 by robert.schadek — 2024-12-13T18:46:46Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19096 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB