{"action":"created","comment":{"url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/comments/26783601","id":26783601,"diff_hunk":"@@ -5205,34 +5215,68 @@ unittest\n         int x;\n         this()     {x = 0;}\n         this(int i){x = i;}\n+        ~this()    {}\n     }\n \n-    // Standard usage\n+    // Standard usage, constructing A on the stack\n     auto a1 = scoped!A();\n-    auto a2 = scoped!A(1);\n     a1.x = 42;\n-    assert(a1.x == 42);\n-    assert(a2.x ==  1);\n+    // Result of `scoped` call implicitly converts to a class reference\n+    A aRef = a1;\n+    assert(aRef.x == 42);\n+    \n+    // Scoped destruction\n+    {\n+        auto a2 = scoped!A(1);\n+        assert(a2.x == 1);\n+        aRef = a2;\n+        // a2 is destroyed here, calling A's destructor\n+    }\n+    // aRef is now an invalid reference\n+\n+    // Below the temporary scoped A is immediately destroyed.\n+    // This means the reference is then invalid.\n+    version(InvalidReference)\n+    {\n+        // Wrong, should use `auto`\n+        A invalid = scoped!A();\n+    }\n \n+    // Use with alias\n+    alias makeScopedA = scoped!A;\n+    auto a3 = makeScopedA();\n+    auto a4 = makeScopedA(1);\n+    \n     // Restrictions\n     static assert(!is(typeof({\n         auto e1 = a1; // illegal, scoped objects can't be copied\n-        assert([a2][0].x == 42); // ditto\n+        assert([a1][0].x == 42); // ditto\n+    })));\n+    static assert(!is(typeof({\n         alias ScopedObject = typeof(a1);\n-        auto e2 = ScopedObject();  //Illegal, must be built via scoped!A\n-        auto e3 = ScopedObject(1); //Illegal, must be built via scoped!A\n+        auto e2 = ScopedObject();  // illegal, must be built via scoped!A\n+        auto e3 = ScopedObject(1); // illegal, must be built via scoped!A\n     })));\n \n     // Use as member variable\n     struct B\n     {\n         typeof(scoped!A()) a; // note the trailing parentheses\n+        \n+        this(int i)\n+        {\n+            // construct member\n+            a = scoped!A(i);\n+        }\n     }\n-\n-    // Use with alias\n-    alias makeScopedA = scoped!A;\n-    auto a6 = makeScopedA();\n-    auto a7 = makeScopedA();\n+    // Stack-allocate\n+    auto b1 = B(5);\n+    aRef = b1.a;\n+    assert(aRef.x == 5);\n+    // Heap-allocate","path":"std/typecons.d","position":109,"original_position":109,"commit_id":"15f66f94eb1462b914dec5da4557d5cf3fe19aca","original_commit_id":"15f66f94eb1462b914dec5da4557d5cf3fe19aca","user":{"login":"quickfur","id":405446,"avatar_url":"https://avatars.githubusercontent.com/u/405446?v=3","gravatar_id":"","url":"https://api.github.com/users/quickfur","html_url":"https://github.com/quickfur","followers_url":"https://api.github.com/users/quickfur/followers","following_url":"https://api.github.com/users/quickfur/following{/other_user}","gists_url":"https://api.github.com/users/quickfur/gists{/gist_id}","starred_url":"https://api.github.com/users/quickfur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quickfur/subscriptions","organizations_url":"https://api.github.com/users/quickfur/orgs","repos_url":"https://api.github.com/users/quickfur/repos","events_url":"https://api.github.com/users/quickfur/events{/privacy}","received_events_url":"https://api.github.com/users/quickfur/received_events","type":"User","site_admin":false},"body":"Nitpick: should have blank line above the comment, for better readability.","created_at":"2015-03-19T18:26:33Z","updated_at":"2015-03-19T18:26:33Z","html_url":"https://github.com/D-Programming-Language/phobos/pull/3016#discussion_r26783601","pull_request_url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3016","_links":{"self":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/comments/26783601"},"html":{"href":"https://github.com/D-Programming-Language/phobos/pull/3016#discussion_r26783601"},"pull_request":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3016"}}},"pull_request":{"url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3016","id":29714374,"html_url":"https://github.com/D-Programming-Language/phobos/pull/3016","diff_url":"https://github.com/D-Programming-Language/phobos/pull/3016.diff","patch_url":"https://github.com/D-Programming-Language/phobos/pull/3016.patch","issue_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/3016","number":3016,"state":"open","locked":false,"title":"Improve docs for `std.typecons.scoped`","user":{"login":"ntrel","id":1107820,"avatar_url":"https://avatars.githubusercontent.com/u/1107820?v=3","gravatar_id":"","url":"https://api.github.com/users/ntrel","html_url":"https://github.com/ntrel","followers_url":"https://api.github.com/users/ntrel/followers","following_url":"https://api.github.com/users/ntrel/following{/other_user}","gists_url":"https://api.github.com/users/ntrel/gists{/gist_id}","starred_url":"https://api.github.com/users/ntrel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ntrel/subscriptions","organizations_url":"https://api.github.com/users/ntrel/orgs","repos_url":"https://api.github.com/users/ntrel/repos","events_url":"https://api.github.com/users/ntrel/events{/privacy}","received_events_url":"https://api.github.com/users/ntrel/received_events","type":"User","site_admin":false},"body":"Show automatic destruction of `scoped` result.\r\nShow how `scoped` can lead to invalid class references.\r\nShow scoped member variable initialization.\r\nMove alias example before *Restrictions* section, which uses alias.","created_at":"2015-02-20T17:30:15Z","updated_at":"2015-03-19T18:26:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"acd05f24c4272dc0c9867d70ff423172690eb559","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3016/commits","review_comments_url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3016/comments","review_comment_url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/comments{/number}","comments_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/3016/comments","statuses_url":"https://api.github.com/repos/D-Programming-Language/phobos/statuses/15f66f94eb1462b914dec5da4557d5cf3fe19aca","head":{"label":"ntrel:scoped-docs","ref":"scoped-docs","sha":"15f66f94eb1462b914dec5da4557d5cf3fe19aca","user":{"login":"ntrel","id":1107820,"avatar_url":"https://avatars.githubusercontent.com/u/1107820?v=3","gravatar_id":"","url":"https://api.github.com/users/ntrel","html_url":"https://github.com/ntrel","followers_url":"https://api.github.com/users/ntrel/followers","following_url":"https://api.github.com/users/ntrel/following{/other_user}","gists_url":"https://api.github.com/users/ntrel/gists{/gist_id}","starred_url":"https://api.github.com/users/ntrel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ntrel/subscriptions","organizations_url":"https://api.github.com/users/ntrel/orgs","repos_url":"https://api.github.com/users/ntrel/repos","events_url":"https://api.github.com/users/ntrel/events{/privacy}","received_events_url":"https://api.github.com/users/ntrel/received_events","type":"User","site_admin":false},"repo":{"id":2997412,"name":"phobos","full_name":"ntrel/phobos","owner":{"login":"ntrel","id":1107820,"avatar_url":"https://avatars.githubusercontent.com/u/1107820?v=3","gravatar_id":"","url":"https://api.github.com/users/ntrel","html_url":"https://github.com/ntrel","followers_url":"https://api.github.com/users/ntrel/followers","following_url":"https://api.github.com/users/ntrel/following{/other_user}","gists_url":"https://api.github.com/users/ntrel/gists{/gist_id}","starred_url":"https://api.github.com/users/ntrel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ntrel/subscriptions","organizations_url":"https://api.github.com/users/ntrel/orgs","repos_url":"https://api.github.com/users/ntrel/repos","events_url":"https://api.github.com/users/ntrel/events{/privacy}","received_events_url":"https://api.github.com/users/ntrel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ntrel/phobos","description":"Runtime library for the D programming language","fork":true,"url":"https://api.github.com/repos/ntrel/phobos","forks_url":"https://api.github.com/repos/ntrel/phobos/forks","keys_url":"https://api.github.com/repos/ntrel/phobos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ntrel/phobos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ntrel/phobos/teams","hooks_url":"https://api.github.com/repos/ntrel/phobos/hooks","issue_events_url":"https://api.github.com/repos/ntrel/phobos/issues/events{/number}","events_url":"https://api.github.com/repos/ntrel/phobos/events","assignees_url":"https://api.github.com/repos/ntrel/phobos/assignees{/user}","branches_url":"https://api.github.com/repos/ntrel/phobos/branches{/branch}","tags_url":"https://api.github.com/repos/ntrel/phobos/tags","blobs_url":"https://api.github.com/repos/ntrel/phobos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ntrel/phobos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ntrel/phobos/git/refs{/sha}","trees_url":"https://api.github.com/repos/ntrel/phobos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ntrel/phobos/statuses/{sha}","languages_url":"https://api.github.com/repos/ntrel/phobos/languages","stargazers_url":"https://api.github.com/repos/ntrel/phobos/stargazers","contributors_url":"https://api.github.com/repos/ntrel/phobos/contributors","subscribers_url":"https://api.github.com/repos/ntrel/phobos/subscribers","subscription_url":"https://api.github.com/repos/ntrel/phobos/subscription","commits_url":"https://api.github.com/repos/ntrel/phobos/commits{/sha}","git_commits_url":"https://api.github.com/repos/ntrel/phobos/git/commits{/sha}","comments_url":"https://api.github.com/repos/ntrel/phobos/comments{/number}","issue_comment_url":"https://api.github.com/repos/ntrel/phobos/issues/comments{/number}","contents_url":"https://api.github.com/repos/ntrel/phobos/contents/{+path}","compare_url":"https://api.github.com/repos/ntrel/phobos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ntrel/phobos/merges","archive_url":"https://api.github.com/repos/ntrel/phobos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ntrel/phobos/downloads","issues_url":"https://api.github.com/repos/ntrel/phobos/issues{/number}","pulls_url":"https://api.github.com/repos/ntrel/phobos/pulls{/number}","milestones_url":"https://api.github.com/repos/ntrel/phobos/milestones{/number}","notifications_url":"https://api.github.com/repos/ntrel/phobos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ntrel/phobos/labels{/name}","releases_url":"https://api.github.com/repos/ntrel/phobos/releases{/id}","created_at":"2011-12-16T20:17:31Z","updated_at":"2014-08-21T11:07:03Z","pushed_at":"2015-03-15T12:33:12Z","git_url":"git://github.com/ntrel/phobos.git","ssh_url":"git@github.com:ntrel/phobos.git","clone_url":"https://github.com/ntrel/phobos.git","svn_url":"https://github.com/ntrel/phobos","homepage":"d-programming-language.org","size":39240,"stargazers_count":1,"watchers_count":1,"language":"D","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"D-Programming-Language:master","ref":"master","sha":"40cd3b513198bd169c06bd6364f4ebfdd3bc0aa5","user":{"login":"D-Programming-Language","id":565913,"avatar_url":"https://avatars.githubusercontent.com/u/565913?v=3","gravatar_id":"","url":"https://api.github.com/users/D-Programming-Language","html_url":"https://github.com/D-Programming-Language","followers_url":"https://api.github.com/users/D-Programming-Language/followers","following_url":"https://api.github.com/users/D-Programming-Language/following{/other_user}","gists_url":"https://api.github.com/users/D-Programming-Language/gists{/gist_id}","starred_url":"https://api.github.com/users/D-Programming-Language/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/D-Programming-Language/subscriptions","organizations_url":"https://api.github.com/users/D-Programming-Language/orgs","repos_url":"https://api.github.com/users/D-Programming-Language/repos","events_url":"https://api.github.com/users/D-Programming-Language/events{/privacy}","received_events_url":"https://api.github.com/users/D-Programming-Language/received_events","type":"Organization","site_admin":false},"repo":{"id":1257084,"name":"phobos","full_name":"D-Programming-Language/phobos","owner":{"login":"D-Programming-Language","id":565913,"avatar_url":"https://avatars.githubusercontent.com/u/565913?v=3","gravatar_id":"","url":"https://api.github.com/users/D-Programming-Language","html_url":"https://github.com/D-Programming-Language","followers_url":"https://api.github.com/users/D-Programming-Language/followers","following_url":"https://api.github.com/users/D-Programming-Language/following{/other_user}","gists_url":"https://api.github.com/users/D-Programming-Language/gists{/gist_id}","starred_url":"https://api.github.com/users/D-Programming-Language/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/D-Programming-Language/subscriptions","organizations_url":"https://api.github.com/users/D-Programming-Language/orgs","repos_url":"https://api.github.com/users/D-Programming-Language/repos","events_url":"https://api.github.com/users/D-Programming-Language/events{/privacy}","received_events_url":"https://api.github.com/users/D-Programming-Language/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/D-Programming-Language/phobos","description":"The standard library of the D programming language","fork":false,"url":"https://api.github.com/repos/D-Programming-Language/phobos","forks_url":"https://api.github.com/repos/D-Programming-Language/phobos/forks","keys_url":"https://api.github.com/repos/D-Programming-Language/phobos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/D-Programming-Language/phobos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/D-Programming-Language/phobos/teams","hooks_url":"https://api.github.com/repos/D-Programming-Language/phobos/hooks","issue_events_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/events{/number}","events_url":"https://api.github.com/repos/D-Programming-Language/phobos/events","assignees_url":"https://api.github.com/repos/D-Programming-Language/phobos/assignees{/user}","branches_url":"https://api.github.com/repos/D-Programming-Language/phobos/branches{/branch}","tags_url":"https://api.github.com/repos/D-Programming-Language/phobos/tags","blobs_url":"https://api.github.com/repos/D-Programming-Language/phobos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/D-Programming-Language/phobos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/D-Programming-Language/phobos/git/refs{/sha}","trees_url":"https://api.github.com/repos/D-Programming-Language/phobos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/D-Programming-Language/phobos/statuses/{sha}","languages_url":"https://api.github.com/repos/D-Programming-Language/phobos/languages","stargazers_url":"https://api.github.com/repos/D-Programming-Language/phobos/stargazers","contributors_url":"https://api.github.com/repos/D-Programming-Language/phobos/contributors","subscribers_url":"https://api.github.com/repos/D-Programming-Language/phobos/subscribers","subscription_url":"https://api.github.com/repos/D-Programming-Language/phobos/subscription","commits_url":"https://api.github.com/repos/D-Programming-Language/phobos/commits{/sha}","git_commits_url":"https://api.github.com/repos/D-Programming-Language/phobos/git/commits{/sha}","comments_url":"https://api.github.com/repos/D-Programming-Language/phobos/comments{/number}","issue_comment_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/comments{/number}","contents_url":"https://api.github.com/repos/D-Programming-Language/phobos/contents/{+path}","compare_url":"https://api.github.com/repos/D-Programming-Language/phobos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/D-Programming-Language/phobos/merges","archive_url":"https://api.github.com/repos/D-Programming-Language/phobos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/D-Programming-Language/phobos/downloads","issues_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues{/number}","pulls_url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls{/number}","milestones_url":"https://api.github.com/repos/D-Programming-Language/phobos/milestones{/number}","notifications_url":"https://api.github.com/repos/D-Programming-Language/phobos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/D-Programming-Language/phobos/labels{/name}","releases_url":"https://api.github.com/repos/D-Programming-Language/phobos/releases{/id}","created_at":"2011-01-15T07:00:06Z","updated_at":"2015-03-19T18:02:53Z","pushed_at":"2015-03-19T18:02:51Z","git_url":"git://github.com/D-Programming-Language/phobos.git","ssh_url":"git@github.com:D-Programming-Language/phobos.git","clone_url":"https://github.com/D-Programming-Language/phobos.git","svn_url":"https://github.com/D-Programming-Language/phobos","homepage":"dlang.org/phobos","size":69992,"stargazers_count":584,"watchers_count":584,"language":"D","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":383,"mirror_url":null,"open_issues_count":57,"forks":383,"open_issues":57,"watchers":584,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3016"},"html":{"href":"https://github.com/D-Programming-Language/phobos/pull/3016"},"issue":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/issues/3016"},"comments":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/issues/3016/comments"},"review_comments":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3016/comments"},"review_comment":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3016/commits"},"statuses":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/statuses/15f66f94eb1462b914dec5da4557d5cf3fe19aca"}}}}