You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling type aliased type class through untyped template param fails.
The example shows the complete cartesian product of
use joined or split functions for the first param, i.e. handle L separately than B or not, and
use the type alias U or R | S in the proc signature for the second param.
Three of these four work, but using joined functions and the type alias U doesn't.
Example
type
R =object
S =object
U = R | S
L =object
B =object
C = B | L
procf(n: L, q: R | S) =echo"L"procf(n: B, q: R | S) =echo"B"procg(n: C, q: R | S) =echo (when n is L: "L"else: "B")
proch(n: L, q: U) =echo"L"proch(n: B, q: U) =echo"B"procj(n: C, q: U) =echo (when n is L: "L"else: "B")
proce(n: B | L, a: R) =templatet(operations: untyped, fn: untyped) =fn(n, operations)
# Work as expectedt(a, f)
t(a, g)
t(a, j)
# Error: type mismatch: got <R, proc [*missing parameters*](n: B, q: U) | proc [*missing parameters*](n: L, q: U)>t(a, h)
e(L(), R())
e(B(), R())
Current Output
please check whether the problem still exists in git head before posting,
see rebuilding the compiler.
type_aliases_with_template.nim(29, 4) Error: type mismatch: got <R, proc [*missing parameters*](n: B, q: U) | proc [*missing parameters*](n: L, q: U)>
but expected one of:
template t(operations: untyped; fn: untyped)
first type mismatch at position: 2
required type for fn: untyped
but expression 'h' is of type: None
expression: t(a, h)
Tested to be the same on:
$ ./env.sh nim --version
Nim Compiler Version 1.2.12 [Linux: amd64]
Compiled at 2021-06-02
Copyright (c) 2006-2020 by Andreas Rumpf
git hash: 121628357ec7fae91335bd392f03b0e6dd249319
active boot switches: -d:release
Nim Compiler Version 1.4.2 [Linux: amd64]
Compiled at 2021-05-13
Copyright (c) 2006-2020 by Andreas Rumpf
active boot switches: -d:release
and the current git head,
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2021-06-06
Copyright (c) 2006-2021 by Andreas Rumpf
git hash: e7816a3e77ab0f821d66667dfc448f1898199f59
active boot switches: -d:release
Expected Output
L
L
L
L
B
B
B
B
The text was updated successfully, but these errors were encountered:
Works in devel, even when changing the signature of t to include typed or have return type untyped. No idea what the root cause was, can't say for certain there isn't another related issue. Doesn't work in 2.0.8. Doesn't seem to need --experimental:openSym.
metagn
added a commit
to metagn/Nim
that referenced
this issue
Dec 8, 2024
Calling type aliased type class through untyped template param fails.
The example shows the complete cartesian product of
L
separately thanB
or not, andU
orR | S
in the proc signature for the second param.Three of these four work, but using joined functions and the type alias
U
doesn't.Example
Current Output
please check whether the problem still exists in git head before posting,
see rebuilding the compiler.
Tested to be the same on:
and the current git head,
Expected Output
The text was updated successfully, but these errors were encountered: