{"action":"created","issue":{"url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/5289","repository_url":"https://api.github.com/repos/HaxeFoundation/haxe","labels_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/5289/labels{/name}","comments_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/5289/comments","events_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/5289/events","html_url":"https://github.com/HaxeFoundation/haxe/issues/5289","id":157356196,"number":5289,"title":"PHP type issue with integer literal edge case","user":{"login":"Jens-G","id":5834733,"avatar_url":"https://avatars.githubusercontent.com/u/5834733?v=3","gravatar_id":"","url":"https://api.github.com/users/Jens-G","html_url":"https://github.com/Jens-G","followers_url":"https://api.github.com/users/Jens-G/followers","following_url":"https://api.github.com/users/Jens-G/following{/other_user}","gists_url":"https://api.github.com/users/Jens-G/gists{/gist_id}","starred_url":"https://api.github.com/users/Jens-G/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Jens-G/subscriptions","organizations_url":"https://api.github.com/users/Jens-G/orgs","repos_url":"https://api.github.com/users/Jens-G/repos","events_url":"https://api.github.com/users/Jens-G/events{/privacy}","received_events_url":"https://api.github.com/users/Jens-G/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/HaxeFoundation/haxe/labels/platform-php","name":"platform-php","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-05-28T20:46:19Z","updated_at":"2016-06-02T08:58:32Z","closed_at":null,"body":"In PHP, the integer constant `-2147483648 = 0x80000000`  is not an integer, but a double:\r\n\r\n```\r\n<?php\r\n$a = gettype(-2147483647);\r\n$b = gettype(-2147483648);\r\necho \"typeof(-2147483647) = $a,  typeof(-2147483648) = $b\";\r\n```\t\r\n[prints this quite surprising result](http://codepad.org/wZ3OxUxv)\r\n\r\n```\t\r\ntypeof(-2147483647) = integer,  typeof(-2147483648) = double\r\n```\t\r\n\r\nIn theory, this looks not as a big issue, but unfortunately it breaks comparison, if the value is indeed stored as an integer, [which is not really hard to achieve](http://codepad.org/jW55kfj9), because Haxe uses the `===` and `!==` operators:\r\n\r\n```\r\n<?php\r\n$a = gettype(-2147483647);\r\n$b = gettype(-2147483648);\r\n$c = gettype(1 << 31);\r\n$d = (-2147483648 === (1 << 31)) ? \"true\" : \"false\";\r\n$e = (-2147483647 === ((1 << 31)+1)) ? \"true\" : \"false\";\r\necho \"types a = $a, b = $b, c = $c \\nequal? -2147483648 = $d, -2147483647 = $e\";\r\n```\r\ngives\r\n```\r\ntypes a = integer, b = double, c = integer \r\nequal? -2147483648 = false, -2147483647 = true\r\n```\r\n \r\nAlthough using `==` and `!=` would solve the actual problem, but I'm not sure about the consequences, so this is probably not really the right way to fix it. \r\n"},"comment":{"url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/comments/223234648","html_url":"https://github.com/HaxeFoundation/haxe/issues/5289#issuecomment-223234648","issue_url":"https://api.github.com/repos/HaxeFoundation/haxe/issues/5289","id":223234648,"user":{"login":"Simn","id":634365,"avatar_url":"https://avatars.githubusercontent.com/u/634365?v=3","gravatar_id":"","url":"https://api.github.com/users/Simn","html_url":"https://github.com/Simn","followers_url":"https://api.github.com/users/Simn/followers","following_url":"https://api.github.com/users/Simn/following{/other_user}","gists_url":"https://api.github.com/users/Simn/gists{/gist_id}","starred_url":"https://api.github.com/users/Simn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Simn/subscriptions","organizations_url":"https://api.github.com/users/Simn/orgs","repos_url":"https://api.github.com/users/Simn/repos","events_url":"https://api.github.com/users/Simn/events{/privacy}","received_events_url":"https://api.github.com/users/Simn/received_events","type":"User","site_admin":false},"created_at":"2016-06-02T08:58:32Z","updated_at":"2016-06-02T08:58:32Z","body":"Yes but doing that for every integer constant is very intrusive. Or am I misunderstanding the scope of this problem?"}}
{"actor":{"display_login":"Simn"}}