{"action":"created","issue":{"url":"https://api.github.com/repos/pawn-lang/compiler/issues/291","repository_url":"https://api.github.com/repos/pawn-lang/compiler","labels_url":"https://api.github.com/repos/pawn-lang/compiler/issues/291/labels{/name}","comments_url":"https://api.github.com/repos/pawn-lang/compiler/issues/291/comments","events_url":"https://api.github.com/repos/pawn-lang/compiler/issues/291/events","html_url":"https://github.com/pawn-lang/compiler/issues/291","id":304162790,"number":291,"title":"Operands are reordered for user-defined + operator with multiple tags","user":{"login":"IllidanS4","id":1337208,"avatar_url":"https://avatars0.githubusercontent.com/u/1337208?v=4","gravatar_id":"","url":"https://api.github.com/users/IllidanS4","html_url":"https://github.com/IllidanS4","followers_url":"https://api.github.com/users/IllidanS4/followers","following_url":"https://api.github.com/users/IllidanS4/following{/other_user}","gists_url":"https://api.github.com/users/IllidanS4/gists{/gist_id}","starred_url":"https://api.github.com/users/IllidanS4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IllidanS4/subscriptions","organizations_url":"https://api.github.com/users/IllidanS4/orgs","repos_url":"https://api.github.com/users/IllidanS4/repos","events_url":"https://api.github.com/users/IllidanS4/events{/privacy}","received_events_url":"https://api.github.com/users/IllidanS4/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2018-03-11T14:29:15Z","updated_at":"2018-03-12T01:28:02Z","closed_at":null,"author_association":"NONE","body":"**Is this a BUG REPORT, FEATURE REQUEST or QUESTION?**:\r\n\r\n* [x] Bug Report\r\n* [ ] Feature Request\r\n* [ ] Question\r\n\r\n**What happened**:\r\nIf I use some sort of a \"better string\" library (this [reference](//github.com/compuphase/pawn/blob/master/include/bstring.inc) one for example) to dynamically create strings, I would also want a string auto-conversion of integers when used to concat with strings:\r\n```pawn\r\nnative String:bstrint(val); //integer to string\r\nstock String:operator+(String:str, val) return bstrcat(val, bstrint(val));\r\nstock String:operator+(val, String:str) return bstrcat(bstrint(val), str);\r\n```\r\nHowever, an expression like `bstring(\"a\")+1+bstring(\"b\")+2` is interpreted in an unexpected manner, producing \"21ab\" instead of \"a1b2\".\r\n\r\n**What you expected to happen**:\r\nEven though standard addition allows any order of operands, user-defined operators should be an exception to this rule in all cases. Since Pawn doesn't reorder the operands for a single-tag operator, it makes no sense to do so when multiple tags are present and multiple user-defined operators for both orders of them are defined.\r\n\r\n**How to reproduce it (as minimally and precisely as possible)**:\r\nDownload [PawnPlus](//github.com/IllidanS4/PawnPlus) and try this code:\r\n```pawn\r\n#include <PawnPlus>\r\nnative print_s(AmxString:string) = print;\r\nstock String:operator+(String:arg1, arg2)\r\n{\r\n    print(\"X\");\r\n    print_s(arg1 % str_new(\"+\") % str_int(arg2));\r\n    return str_cat(arg1, str_int(arg2));\r\n}\r\nstock String:operator+(arg1, String:arg2)\r\n{\r\n    print(\"Y\");\r\n    print_s(str_int(arg1) % str_new(\"+\") % arg2);\r\n    return str_cat(str_int(arg1), arg2);\r\n}\r\nmain()\r\n{\r\n    print_s(str_new(\"a\")+1);\r\n}\r\n```\r\n\r\n**Anything else we need to know?**:\r\nThe operator marked \"Y\" is called in _any_ case, even when the opposite order of tags is used. The order of definitions of operators doesn't make a difference.\r\n\r\n**Environment**:\r\n\r\n* Windows 7, 64-bit\r\n* pawnc v3.10.6\r\n"},"comment":{"url":"https://api.github.com/repos/pawn-lang/compiler/issues/comments/372169103","html_url":"https://github.com/pawn-lang/compiler/issues/291#issuecomment-372169103","issue_url":"https://api.github.com/repos/pawn-lang/compiler/issues/291","id":372169103,"user":{"login":"Y-Less","id":991078,"avatar_url":"https://avatars1.githubusercontent.com/u/991078?v=4","gravatar_id":"","url":"https://api.github.com/users/Y-Less","html_url":"https://github.com/Y-Less","followers_url":"https://api.github.com/users/Y-Less/followers","following_url":"https://api.github.com/users/Y-Less/following{/other_user}","gists_url":"https://api.github.com/users/Y-Less/gists{/gist_id}","starred_url":"https://api.github.com/users/Y-Less/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Y-Less/subscriptions","organizations_url":"https://api.github.com/users/Y-Less/orgs","repos_url":"https://api.github.com/users/Y-Less/repos","events_url":"https://api.github.com/users/Y-Less/events{/privacy}","received_events_url":"https://api.github.com/users/Y-Less/received_events","type":"User","site_admin":false},"created_at":"2018-03-12T01:28:02Z","updated_at":"2018-03-12T01:28:02Z","author_association":"OWNER","body":"> I feel I have already sufficiently demonstrated that the order of operands does matter at least for floating point types, so I see no point in attempting to prove it further\r\n\r\nThe demonstration you gave where rearranging produced a better, more accurate, result?"}}
{"actor":{"display_login":"Y-Less"}}