D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 8070 - associative array element is created before value is ready
Summary: associative array element is created before value is ready
Status: RESOLVED DUPLICATE of issue 3825
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-09 00:03 UTC by luka8088
Modified: 2012-05-09 00:21 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description luka8088 2012-05-09 00:03:22 UTC
I may be mistaken but, as far as I know the fact that 'arr["x"] is created and set to null' before 'new object of class A is created' is a bug. Right ?

--------------------------------------------------------

/* Order of execution (is this a bug ?):
 *   - arr["x"] is created and set to null
 *   - new object of class A is created
 *   - arr["x"] is set to newly created object
 */
 
module program;
 
A[string] arr;
 
class A {
  
  this () {
    // at this point:
    // ("x" in arr)   is true
    // arr["x"]       is set to null
  }
  
}
 
void main () {
  arr["x"] = new A();
}
Comment 1 Jonathan M Davis 2012-05-09 00:21:06 UTC

*** This issue has been marked as a duplicate of issue 3825 ***