{"action":"created","issue":{"url":"https://api.github.com/repos/magic-lang/rock/issues/79","repository_url":"https://api.github.com/repos/magic-lang/rock","labels_url":"https://api.github.com/repos/magic-lang/rock/issues/79/labels{/name}","comments_url":"https://api.github.com/repos/magic-lang/rock/issues/79/comments","events_url":"https://api.github.com/repos/magic-lang/rock/issues/79/events","html_url":"https://github.com/magic-lang/rock/issues/79","id":188198945,"number":79,"title":"Is operator `as` unreliable when testing for inheritance ?","user":{"login":"sebastianbaginski","id":13517893,"avatar_url":"https://avatars.githubusercontent.com/u/13517893?v=3","gravatar_id":"","url":"https://api.github.com/users/sebastianbaginski","html_url":"https://github.com/sebastianbaginski","followers_url":"https://api.github.com/users/sebastianbaginski/followers","following_url":"https://api.github.com/users/sebastianbaginski/following{/other_user}","gists_url":"https://api.github.com/users/sebastianbaginski/gists{/gist_id}","starred_url":"https://api.github.com/users/sebastianbaginski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebastianbaginski/subscriptions","organizations_url":"https://api.github.com/users/sebastianbaginski/orgs","repos_url":"https://api.github.com/users/sebastianbaginski/repos","events_url":"https://api.github.com/users/sebastianbaginski/events{/privacy}","received_events_url":"https://api.github.com/users/sebastianbaginski/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-11-09T09:20:30Z","updated_at":"2016-11-09T09:48:52Z","closed_at":"2016-11-09T09:37:59Z","body":"```ooc\r\nuse base\r\n\r\nBase: abstract class {\r\n\tinit: func\r\n\tdoit: abstract func\r\n}\r\n\r\nGoodClass: class extends Base {\r\n\tinit: func\r\n\tdoit: override func { \"good\" println() }\r\n}\r\n\r\nBadClass: class extends Base {\r\n\tinit: func\r\n\tdoit: override func { \"VERY BAD\" println() }\r\n}\r\n\r\ninstance: Base\r\ninstance = BadClass new()\r\nif (instance as GoodClass)\r\n\tinstance doit()\r\n\r\n```\r\n\r\noutput:\r\n\r\n> VERY BAD\r\n\r\nIs it unsafe to use `operator as` to test for a `is a kind of` - type of relation ? I would expect `instance as GoodClass` to fail because `instance` is an object of the `BadClass`.\r\nDo I have an error somewhere in my code (or are my assumptions about the \"as\" operator incorrect) ?\r\n@thomasfanell "},"comment":{"url":"https://api.github.com/repos/magic-lang/rock/issues/comments/259373621","html_url":"https://github.com/magic-lang/rock/issues/79#issuecomment-259373621","issue_url":"https://api.github.com/repos/magic-lang/rock/issues/79","id":259373621,"user":{"login":"marcusnaslund","id":14308896,"avatar_url":"https://avatars.githubusercontent.com/u/14308896?v=3","gravatar_id":"","url":"https://api.github.com/users/marcusnaslund","html_url":"https://github.com/marcusnaslund","followers_url":"https://api.github.com/users/marcusnaslund/followers","following_url":"https://api.github.com/users/marcusnaslund/following{/other_user}","gists_url":"https://api.github.com/users/marcusnaslund/gists{/gist_id}","starred_url":"https://api.github.com/users/marcusnaslund/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcusnaslund/subscriptions","organizations_url":"https://api.github.com/users/marcusnaslund/orgs","repos_url":"https://api.github.com/users/marcusnaslund/repos","events_url":"https://api.github.com/users/marcusnaslund/events{/privacy}","received_events_url":"https://api.github.com/users/marcusnaslund/received_events","type":"User","site_admin":false},"created_at":"2016-11-09T09:48:52Z","updated_at":"2016-11-09T09:48:52Z","body":"Indeed, `as` is used for casting to another type, not for checking current type. I think you may cast any class to any class and it won't fail until you try to use it the wrong way."}}
{"actor":{"display_login":"marcusnaslund"}}