{"action":"created","issue":{"url":"https://api.github.com/repos/construct/construct/issues/269","repository_url":"https://api.github.com/repos/construct/construct","labels_url":"https://api.github.com/repos/construct/construct/issues/269/labels{/name}","comments_url":"https://api.github.com/repos/construct/construct/issues/269/comments","events_url":"https://api.github.com/repos/construct/construct/issues/269/events","html_url":"https://github.com/construct/construct/issues/269","id":187193564,"number":269,"title":"Switch field is required in obj even if condition will evaluate to a flagbuildnone subcon","user":{"login":"Schamper","id":1254028,"avatar_url":"https://avatars.githubusercontent.com/u/1254028?v=3","gravatar_id":"","url":"https://api.github.com/users/Schamper","html_url":"https://github.com/Schamper","followers_url":"https://api.github.com/users/Schamper/followers","following_url":"https://api.github.com/users/Schamper/following{/other_user}","gists_url":"https://api.github.com/users/Schamper/gists{/gist_id}","starred_url":"https://api.github.com/users/Schamper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Schamper/subscriptions","organizations_url":"https://api.github.com/users/Schamper/orgs","repos_url":"https://api.github.com/users/Schamper/repos","events_url":"https://api.github.com/users/Schamper/events{/privacy}","received_events_url":"https://api.github.com/users/Schamper/received_events","type":"User","site_admin":false},"labels":[{"id":440735494,"url":"https://api.github.com/repos/construct/construct/labels/question","name":"question","color":"1d76db","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-11-03T21:20:57Z","updated_at":"2016-11-04T18:26:23Z","closed_at":null,"body":"This fails with a `KeyError: 'b'`:\r\n```\r\nStruct(\"a\" / Byte, \"b\" / If(this.a == 1, Padding(2))).build(Container(a=1))\r\n```\r\n\r\nThough this succeeds, even though the `b` key is useless:\r\n```\r\nStruct(\"a\" / Byte, \"b\" / If(this.a == 1, Padding(2))).build(Container(a=1, b=0))\r\n```\r\n\r\nLet me know if you want a unit test added for this."},"comment":{"url":"https://api.github.com/repos/construct/construct/issues/comments/258511281","html_url":"https://github.com/construct/construct/issues/269#issuecomment-258511281","issue_url":"https://api.github.com/repos/construct/construct/issues/269","id":258511281,"user":{"login":"Schamper","id":1254028,"avatar_url":"https://avatars.githubusercontent.com/u/1254028?v=3","gravatar_id":"","url":"https://api.github.com/users/Schamper","html_url":"https://github.com/Schamper","followers_url":"https://api.github.com/users/Schamper/followers","following_url":"https://api.github.com/users/Schamper/following{/other_user}","gists_url":"https://api.github.com/users/Schamper/gists{/gist_id}","starred_url":"https://api.github.com/users/Schamper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Schamper/subscriptions","organizations_url":"https://api.github.com/users/Schamper/orgs","repos_url":"https://api.github.com/users/Schamper/repos","events_url":"https://api.github.com/users/Schamper/events{/privacy}","received_events_url":"https://api.github.com/users/Schamper/received_events","type":"User","site_admin":false},"created_at":"2016-11-04T18:26:23Z","updated_at":"2016-11-04T18:26:23Z","body":"`If` was just as an example, but in my case I have a `Switch` that can return a `Pass` as the default.\r\n It's not that big a deal in my personal case but merely an interesting detail I noticed.\r\n\r\nhttps://github.com/construct/construct/blob/master/construct/core.py#L870-L873\r\n\r\nMaybe add a `flagbuildoptional` which will behave the same as `flagbuildnone`?"}}
{"actor":{"display_login":"Schamper"}}