-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Distinct generic parameter types #1385
Comments
Got another example (seems more similar than I initially thought) type
A*[T] = distinct T
B*[T] = distinct T
AB*[T] = A[T] or B[T]
proc `==`*[T](x: distinct AB[T], y: distinct AB[T]): bool =
true
var a: A[string]
var b: B[string]
assert(a == b)
|
This bug is still not fixed. In Nim manual, there is following example code: proc p(a: Table, b: distinct Table)
# is roughly the same as:
proc p[Key, Value, KeyB, ValueB](a: Table[Key, Value], b: Table[KeyB, ValueB]) But this code results in compile error. import tables
proc p(a: Table, b: distinct Table) =
discard
proc p2[Key, Value, KeyB, ValueB](a: Table[Key, Value], b: Table[KeyB, ValueB]) =
discard
var
x: Table[int, string]
y: Table[string, int]
# p2 works
p2(x, y)
# Compile error:
p(x, y)
Nim devel version:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would expect this code to work, but get a type mismatch:
On a related note, maybe this is also supposed to work:
But it seems to suffer from the same problem.
The text was updated successfully, but these errors were encountered: