Created
February 3, 2019 03:15
-
-
Save qxxxb/7dcdbf9497480be4c2e756951dab618d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type | |
Foo = object of RootObj | |
Bar = object of Foo | |
Baz = object of Foo | |
proc castMaybe(foo: var Foo) = | |
if foo of Bar: | |
foo = Baz(foo) | |
var b: Foo | |
b = Bar() | |
castMaybe(b) | |
doAssert b of Baz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compiles but throws ObjectAssignmentError at line 11