Skip to content

Instantly share code, notes, and snippets.

@qxxxb
Created February 3, 2019 03:15
Show Gist options
  • Save qxxxb/7dcdbf9497480be4c2e756951dab618d to your computer and use it in GitHub Desktop.
Save qxxxb/7dcdbf9497480be4c2e756951dab618d to your computer and use it in GitHub Desktop.
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
@qxxxb
Copy link
Author

qxxxb commented Feb 3, 2019

Compiles but throws ObjectAssignmentError at line 11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment