{"action":"created","issue":{"url":"https://api.github.com/repos/ethereum/solidity/issues/583","repository_url":"https://api.github.com/repos/ethereum/solidity","labels_url":"https://api.github.com/repos/ethereum/solidity/issues/583/labels{/name}","comments_url":"https://api.github.com/repos/ethereum/solidity/issues/583/comments","events_url":"https://api.github.com/repos/ethereum/solidity/issues/583/events","html_url":"https://github.com/ethereum/solidity/issues/583","id":155647092,"number":583,"title":"Bug? in resolving msg.sender in message call in constructor","user":{"login":"dwhjames","id":470008,"avatar_url":"https://avatars.githubusercontent.com/u/470008?v=3","gravatar_id":"","url":"https://api.github.com/users/dwhjames","html_url":"https://github.com/dwhjames","followers_url":"https://api.github.com/users/dwhjames/followers","following_url":"https://api.github.com/users/dwhjames/following{/other_user}","gists_url":"https://api.github.com/users/dwhjames/gists{/gist_id}","starred_url":"https://api.github.com/users/dwhjames/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwhjames/subscriptions","organizations_url":"https://api.github.com/users/dwhjames/orgs","repos_url":"https://api.github.com/users/dwhjames/repos","events_url":"https://api.github.com/users/dwhjames/events{/privacy}","received_events_url":"https://api.github.com/users/dwhjames/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2016-05-19T03:26:42Z","updated_at":"2016-05-20T12:31:34Z","closed_at":null,"body":"This seems like a compiler bug to me, unless I have a misunderstanding here…\r\n\r\nConsider the contract\r\n```js\r\ncontract PingPong {\r\n    function PingPong() {\r\n        this.foo(msg.sender, msg.value);\r\n    }\r\n    function () {\r\n        this.foo(msg.sender, msg.value);\r\n    }\r\n    function foo(address originalSender, uint originalValue) {\r\n        originalSender.send(originalValue);\r\n    }\r\n}\r\n```\r\n\r\nYou can see this deployed on Morden here: [0x1689e1992bc3690383d74d439e4055c34a2640fe](http://testnet.etherscan.io/address/0x1689e1992bc3690383d74d439e4055c34a2640fe)\r\n\r\nUpon contract creation, I was expecting the value sent with the tx to be bounced back to the sender. Instead, the contract ends up sending the ETH to itself in an internal tx: `msg.sender` was resolved to the address of the newly created contract _not_ the true sender.\r\n\r\n(The default method works as expected: two internal txs, the second returning the ETH to the original sender.)\r\n\r\nLifting `msg.sender` to a local name makes no difference:\r\n\r\n```js\r\ncontract PingPong {\r\n    function PingPong() {\r\n        address originalSender = msg.sender;\r\n        uint originalValue = msg.value;\r\n        this.foo(originalSender, originalValue);\r\n    }\r\n…\r\n```\r\n\r\nOnly an internal method call works as expected:\r\n\r\n```js\r\ncontract PingPong {\r\n    function PingPong() {\r\n        foo(msg.value, msg.sender);\r\n    }\r\n…\r\n```\r\n\r\nIs this a bug? Have I misunderstood something special about the constructor?"},"comment":{"url":"https://api.github.com/repos/ethereum/solidity/issues/comments/220593233","html_url":"https://github.com/ethereum/solidity/issues/583#issuecomment-220593233","issue_url":"https://api.github.com/repos/ethereum/solidity/issues/583","id":220593233,"user":{"login":"chriseth","id":9073706,"avatar_url":"https://avatars.githubusercontent.com/u/9073706?v=3","gravatar_id":"","url":"https://api.github.com/users/chriseth","html_url":"https://github.com/chriseth","followers_url":"https://api.github.com/users/chriseth/followers","following_url":"https://api.github.com/users/chriseth/following{/other_user}","gists_url":"https://api.github.com/users/chriseth/gists{/gist_id}","starred_url":"https://api.github.com/users/chriseth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chriseth/subscriptions","organizations_url":"https://api.github.com/users/chriseth/orgs","repos_url":"https://api.github.com/users/chriseth/repos","events_url":"https://api.github.com/users/chriseth/events{/privacy}","received_events_url":"https://api.github.com/users/chriseth/received_events","type":"User","site_admin":false},"created_at":"2016-05-20T12:31:34Z","updated_at":"2016-05-20T12:31:34Z","body":"Yes, it is an internal transaction that does nothing."}}
{"actor":{"display_login":"chriseth"}}