Open PMunch opened 5 months ago
Same issue as #16148 (though this is only realized after 15 comments), related is #15154 but this is a simpler case of just proc foo[T](a, b: ptr T)
.
If nil
is matching ptr T
and resolving T to itself (i.e. T = T
vs T = nil
) or stopping the resolution of T in some other simple way then this should be fixable (isGeneric?), but if T is being resolved to int and the type of the nil parameter is not populated after the fact then this is a limitation and we need to detect if we assign an unresolved type to a position that won't be populated with resolved parameters later.
Very easy bandaid is:
proc `==`[T](a: typeof(nil) | typeof(nil), b: T) {.magic: "WhateverMagicPointerEqualityUses".}
but in general typeof(nil) | typeof(nil)
is a hack and there is a chance this is easy to fix in the compiler.
Description
Fairly simple, passed some C code through c2nim and it spat out some
if nil == X
statements. These statements unfortunately crash the compiler withError: internal error: getTypeDescAux(tyGenericParam)
so figuring out what was wrong was a bit annoying. It works iftypeof(X)
ispointer
, but crashes if it is for exampleptr int
.Nim Version
Nim Compiler Version 2.0.4 [Linux: amd64] Compiled at 2024-03-28 Copyright (c) 2006-2023 by Andreas Rumpf
git hash: b47747d31844c6bd9af4322efe55e24fefea544c active boot switches: -d:release
Current Output
Expected Output
Possible Solution
No response
Additional Information