Created
February 28, 2016 17:48
-
-
Save gmpreussner/2128bb16112e194ff53c to your computer and use it in GitHub Desktop.
This file contains hidden or 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[T] = ref object | |
x: T | |
Bar[N: static[int], T] = ref object | |
a: array[N, T] | |
x: T | |
Foobar[N: static[int], T] = object | |
b: Bar[N, T] | |
proc foobar[N, T](x: var Foobar[N, T]) = | |
x.b = Bar[N, T](x: 42) # !!! | |
when isMainModule: | |
var f = Foo[int](x: 42) # works | |
var b = Bar[10, int](x: 42) # works | |
var fb: Foobar[10, int] # works | |
fb.b = Bar[10, int](x: 42) | |
fb.foobar # Error: object constructor needs an object type |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works: