{"action":"created","issue":{"url":"https://api.github.com/repos/fastbuild/fastbuild/issues/117","repository_url":"https://api.github.com/repos/fastbuild/fastbuild","labels_url":"https://api.github.com/repos/fastbuild/fastbuild/issues/117/labels{/name}","comments_url":"https://api.github.com/repos/fastbuild/fastbuild/issues/117/comments","events_url":"https://api.github.com/repos/fastbuild/fastbuild/issues/117/events","html_url":"https://github.com/fastbuild/fastbuild/pull/117","id":163737212,"number":117,"title":"Improve variable handling logic","user":{"login":"dummyunit","id":2660083,"avatar_url":"https://avatars.githubusercontent.com/u/2660083?v=3","gravatar_id":"","url":"https://api.github.com/users/dummyunit","html_url":"https://github.com/dummyunit","followers_url":"https://api.github.com/users/dummyunit/followers","following_url":"https://api.github.com/users/dummyunit/following{/other_user}","gists_url":"https://api.github.com/users/dummyunit/gists{/gist_id}","starred_url":"https://api.github.com/users/dummyunit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dummyunit/subscriptions","organizations_url":"https://api.github.com/users/dummyunit/orgs","repos_url":"https://api.github.com/users/dummyunit/repos","events_url":"https://api.github.com/users/dummyunit/events{/privacy}","received_events_url":"https://api.github.com/users/dummyunit/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/fastbuild/fastbuild/labels/Enhancement","name":"Enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-04T20:00:41Z","updated_at":"2016-07-10T15:58:08Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/fastbuild/fastbuild/pulls/117","html_url":"https://github.com/fastbuild/fastbuild/pull/117","diff_url":"https://github.com/fastbuild/fastbuild/pull/117.diff","patch_url":"https://github.com/fastbuild/fastbuild/pull/117.patch"},"body":"This series of commits bans most ways for a variable to change its type, which were discovered in #113, by adding checks that ensure that variable to be modified has same or compatible type.\r\n\r\nIt also fixes some others bugs/inconsistencies discovered along the way:\r\n   - Subtraction operator wasn't handled properly in many cases. In operations where right operand was variable or explicit structure it worked like assignment. With this changes:\r\n      1. Subtractions of structs are banned.\r\n      2. Subtractions like `.String1 - .String2` work like `.String1 - \"explicit string\"`, removing occurrences of `.String2` from `.String1`.\r\n      3. Subtractions like `.ArrayOfStrings - .String` work like `.ArrayOfStrings - \"explicit string\"`, removing elements that are equal to `.String` from `.ArrayOfStrings`.\r\n      4. Added subtractions for integers (that was easier than adding error message :) ).\r\n      5. Other subtractions are banned (bool and arrays).\r\n   - Integer addition only worked when right operand was a variable. With this changes it will work with explicit values as well.\r\n\r\nI have also changed bool value parsing to be more clear and not use cryptic constructions like `iter.ParseToNext( 'e' )`.\r\n\r\nI must also mention that with these fixes code structured like that (which probably used by many people) now produces an error:\r\n```\r\n$ cat test.bff \r\n.EnabledX = { \"Foo\" \"Bar\" }\r\n.Array = {}\r\nForEach( .X in .EnabledX )\r\n{\r\n        .Struct =\r\n        [\r\n                .A = .X\r\n                .B = \"-option $X$\"\r\n        ]\r\n        ^Array + { .Struct }\r\n}\r\n$ fbuild -verbose -config test.bff\r\nRegistered <ArrayOfStrings> variable '.EnabledX' with 2 elements\r\nRegistered <ArrayOfStrings> variable '.Array' with 0 elements\r\nFunction call 'ForEach'\r\nFreezing loop array '.EnabledX' of type <ArrayOfStrings>\r\nRegistered <string> variable '.A' with value 'Foo'\r\nRegistered <string> variable '.B' with value '-option Foo'\r\nRegistered <struct> variable '.Struct' with 2 members\r\n/home/dummyunit/fastbuild/Code/test.bff(10,13): FASTBuild Error #1034 - Operation not supported: 'ArrayOfStrings' + 'Struct'.\r\n        ^Array + { .Struct }\r\n                   ^\r\n                   \\--here\r\n```\r\nSo, if this will be merged, something must done to support empty arrays — either updated version of #110 or different internal type for fresh empty arrays (like I described in comment 3 in #110), or something else."},"comment":{"url":"https://api.github.com/repos/fastbuild/fastbuild/issues/comments/231596158","html_url":"https://github.com/fastbuild/fastbuild/pull/117#issuecomment-231596158","issue_url":"https://api.github.com/repos/fastbuild/fastbuild/issues/117","id":231596158,"user":{"login":"dummyunit","id":2660083,"avatar_url":"https://avatars.githubusercontent.com/u/2660083?v=3","gravatar_id":"","url":"https://api.github.com/users/dummyunit","html_url":"https://github.com/dummyunit","followers_url":"https://api.github.com/users/dummyunit/followers","following_url":"https://api.github.com/users/dummyunit/following{/other_user}","gists_url":"https://api.github.com/users/dummyunit/gists{/gist_id}","starred_url":"https://api.github.com/users/dummyunit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dummyunit/subscriptions","organizations_url":"https://api.github.com/users/dummyunit/orgs","repos_url":"https://api.github.com/users/dummyunit/repos","events_url":"https://api.github.com/users/dummyunit/events{/privacy}","received_events_url":"https://api.github.com/users/dummyunit/received_events","type":"User","site_admin":false},"created_at":"2016-07-10T15:58:08Z","updated_at":"2016-07-10T15:58:08Z","body":"Done. Rebased on top of dev and adjusted some commits (mostly the first 2).\r\n\r\nAlso added one new commit (the last one) that fixes one rare case I didn't account for in #110: addition/subtraction/assignment of explicit string to empty ArrayOfStructs wasn't working, while the same with string _variable_ and empty ArrayOfStructs was."}}
{"actor":{"display_login":"dummyunit"}}