nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.55k stars 1.47k forks source link

Type -> Type -> template fails to compile #20367

Open rotu opened 2 years ago

rotu commented 2 years ago

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

metagn commented 1 week ago

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