Nim icon indicating copy to clipboard operation
Nim copied to clipboard

Type -> Type -> template fails to compile

Open rotu opened this issue 3 years ago • 1 comments

What happened?

Defining a type via template by means of an intermediate generic type fails. This occurs whether the generic parameter is a type or a static value.

template someTemp(T:type):typedesc = T
type
    Foo[T2:type] = someTemp(T2)
    Bar[T1:type] = Foo[T1]
var u:Foo[float] # works
var v:Bar[float] # Error: invalid type: 'None' in this context: 'Bar[system.float]' for var
template someOtherTemp(p:static[int]):untyped = array[p,int]
type
    Foo2[n:static[int]] = someOtherTemp(n)
    Bar2[m:static[int]] = Foo2[m]
var x:Foo2[1] # works
var y:Bar2[1] # Error: undeclared identifier: 'n'

Nim Version

Nim Compiler Version 1.7.1 [MacOSX: amd64] Compiled at 2022-09-15 Copyright (c) 2006-2022 by Andreas Rumpf

git hash: 79afee868d784eb90972deb3ea89c96702585968 active boot switches: -d:release

Current Standard Output Logs

No response

Expected Standard Output Logs

No response

Possible Solution

No response

Additional Information

No response

rotu avatar Sep 16 '22 04:09 rotu

Second example now works, first example works if : type is removed

metagn avatar Oct 14 '24 09:10 metagn