-
Notifications
You must be signed in to change notification settings - Fork 7
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
make empty seq literals work #470
Comments
Thought about it for a while, best I've come up with so far is:
For seqs, provided they stay completely independent from the compiler:
This does not have to stack with converters as it already doesn't in the old compiler. What calls are allowed to be "empty literal calls" can be restricted as much as necessary given they match Instantiating the parameter type to perform the flipped match imply that should be done in sem and not in sigmatch, but it doesn't really make sense to do this after the matches fail like converters given that the empty literal call arguments will always fail to match if not handled. Doing them in sigmatch would mean we still need Another option might be to make the compiler aware of Final note: To make |
Random idea: Just make template `@`[I, T](x: array[I, T]): array[I, T] = x
|
Though ideally @ is just: proc `@`*[I, T](a: array[I, T]): seq[T] {.nodestroy.} =
result = newSeqUninit[T](a.len)
var i = 0
while i < result.len:
(result.data[i]) = `=dup`(a[i])
inc i
Maybe if we make @ a magic that has a special typing rule allowing for the empty array |
Could use something like
--experimental:inferGenericParams
and depend on top down type inference, but this probably wouldn't be able to handle:So we might still need to use an
Empty
type as in the old compiler but make sure it always gets checked.This case already doesn't work in the old compiler:
The text was updated successfully, but these errors were encountered: