{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/hhvm/issues/5315","labels_url":"https://api.github.com/repos/facebook/hhvm/issues/5315/labels{/name}","comments_url":"https://api.github.com/repos/facebook/hhvm/issues/5315/comments","events_url":"https://api.github.com/repos/facebook/hhvm/issues/5315/events","html_url":"https://github.com/facebook/hhvm/issues/5315","id":74430872,"number":5315,"title":"Inconsistency with ~ bitwise operator on string","user":{"login":"5lava","id":63829,"avatar_url":"https://avatars.githubusercontent.com/u/63829?v=3","gravatar_id":"","url":"https://api.github.com/users/5lava","html_url":"https://github.com/5lava","followers_url":"https://api.github.com/users/5lava/followers","following_url":"https://api.github.com/users/5lava/following{/other_user}","gists_url":"https://api.github.com/users/5lava/gists{/gist_id}","starred_url":"https://api.github.com/users/5lava/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/5lava/subscriptions","organizations_url":"https://api.github.com/users/5lava/orgs","repos_url":"https://api.github.com/users/5lava/repos","events_url":"https://api.github.com/users/5lava/events{/privacy}","received_events_url":"https://api.github.com/users/5lava/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/hhvm/labels/hack","name":"hack","color":"fe8700"},{"url":"https://api.github.com/repos/facebook/hhvm/labels/won't%20fix","name":"won't fix","color":"FF00FF"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-08T17:11:22Z","updated_at":"2015-05-08T21:38:40Z","closed_at":"2015-05-08T17:23:56Z","body":"(HHVM 3.7.0)\r\n```php\r\n<?hh // strict\r\nfunction f():string {\r\n\treturn ~\"xxx\";\r\n}\r\n```\r\n\r\nResult:\r\n```\r\nTyping error (Typing[4110])\r\nThis is an int because this is used in an arithmetic operation\r\nIt is incompatible with a string\r\n```\r\n\r\nHowever:\r\n```php\r\n<?hh\r\nassert(~\"xxx\" instanceof string);\r\nvar_dump(~\"xxx\");\r\n```\r\nconfirms `~\"xxx\"` it's still a string.\r\n\r\nPHP documentation (http://php.net/manual/en/language.operators.bitwise.php): *If the operand for the ~ operator is a string, the operation will be performed on the ASCII values of the characters that make up the string and the result will be a string*.\r\n\r\nHack documentation (http://docs.hhvm.com/manual/en/language.operators.bitwise.php) is not clear about that."},"comment":{"url":"https://api.github.com/repos/facebook/hhvm/issues/comments/100375434","html_url":"https://github.com/facebook/hhvm/issues/5315#issuecomment-100375434","issue_url":"https://api.github.com/repos/facebook/hhvm/issues/5315","id":100375434,"user":{"login":"5lava","id":63829,"avatar_url":"https://avatars.githubusercontent.com/u/63829?v=3","gravatar_id":"","url":"https://api.github.com/users/5lava","html_url":"https://github.com/5lava","followers_url":"https://api.github.com/users/5lava/followers","following_url":"https://api.github.com/users/5lava/following{/other_user}","gists_url":"https://api.github.com/users/5lava/gists{/gist_id}","starred_url":"https://api.github.com/users/5lava/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/5lava/subscriptions","organizations_url":"https://api.github.com/users/5lava/orgs","repos_url":"https://api.github.com/users/5lava/repos","events_url":"https://api.github.com/users/5lava/events{/privacy}","received_events_url":"https://api.github.com/users/5lava/received_events","type":"User","site_admin":false},"created_at":"2015-05-08T21:38:40Z","updated_at":"2015-05-08T21:38:40Z","body":"Thank you Paul."}}