Open
Description
Example
type
# INVALID v INVALID
HyalosTracker*[T; N: static int] = ref HyalosTrackerObj[T, N] #<- type expected, but expression has no type
HyalosTrackerObj*[T; N: static int] = object
# ...
# Valid if 'typeof N' used
HyalosTracker*[T; N: static int] = ref HyalosTrackerObj[T, typeof N] # Valid
HyalosTrackerObj*[T; N: static int] = object
# ...
# Valid if remove static hint/requirement
HyalosTracker*[T; N: int] = ref HyalosTrackerObj[T, N] # Valid
HyalosTrackerObj*[T; N: static int] = object
# ...
# Valid by reordering Obj decl before ref
HyalosTrackerObj*[T; N: static int] = object # Valid
HyalosTracker*[T; N: static int] = ref HyalosTrackerObj[T, N]
Additional Information
What is the accepted outcome in this situation?
Under previous main line versions, I am used to the first 'mostly' functioning. However, I don't understand why this would be valid:
type
# Valid if 'typeof N' used
HyalosTracker*[T; N: static int] = ref HyalosTrackerObj[T, typeof N] # Valid
HyalosTrackerObj*[T; N: static int] = object
If N is a compiletime literal I'm passing through the generic type to predetermine fields such as array sizes, then I would expect this of all to fail. As a disclaimer, this is what I would expect to happen from my shallow understanding. I will do some investigation to determine possible sources for this behaviour in the compiler but would like to understand what we view as being valid and what is invalid from the get go.
This can even be sidelined until static and generics are visited in depth in the compiler.