Skip to content

Instantly share code, notes, and snippets.

@gmpreussner
Created October 18, 2015 06:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmpreussner/42316c11c9c6d4479d21 to your computer and use it in GitHub Desktop.
Save gmpreussner/42316c11c9c6d4479d21 to your computer and use it in GitHub Desktop.
Bug with generics/concepts
type
Foo[T] = concept x, y
foo(x, y) is bool
Bar[T] = object
b: T
when true: # the following works
proc foo(x, y: Bar): bool = true
when false: # this does not (unit test fails)
proc foo(x, y: Bar): bool = x.b < y.b
when false: # workaround
proc foo(x, y: Bar): bool = result = x.b < y.b
test "foo":
check(Bar[int] is Foo[int])
@gmpreussner
Copy link
Author

Not sure if this is a problem with concepts, generics, or type inference, or a combination of those.

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