Files
Nim/tests/generics/tpointerprocs.nim
ringabout bd709f9b4c fixes #25262; proc v[T: typedesc]() = discard / v[0]() compiles even though 0 isn't a typedesc (#25558)
fixes #25262

```nim
if constraint != nil and constraint.kind == tyTypeDesc:
  n[i].typ = e.typ
else:
  n[i].typ = e.typ.skipTypes({tyTypeDesc})
```
at least when `constraint` is a typedesc, it should not skip
`tyTypeDesc`


```nim
if arg.kind != tyTypeDesc:
  arg = makeTypeDesc(m.c, arg)
```
Wrappers literals into typedesc, which can cause problems. Though, it
doesn't seem to be necessary
2026-02-28 23:01:09 +01:00

36 lines
986 B
Nim

discard """
cmd: "nim check $options --hints:off $file"
action: "reject"
nimout:'''
tpointerprocs.nim(22, 11) Error: 'foo' doesn't have a concrete type, due to unspecified generic parameters.
tpointerprocs.nim(34, 14) Error: type mismatch: got <typedesc[int]>
but expected one of:
proc foo(x: int | float; y: int or string): float
first type mismatch at position: 2 in generic parameters
missing generic parameter: y:type
expression: foo[int]
tpointerprocs.nim(34, 14) Error: cannot instantiate: 'foo[int]'
tpointerprocs.nim(34, 14) Error: expression 'foo[int]' has no type (or is ambiguous)
tpointerprocs.nim(35, 11) Error: expression 'bar' has no type (or is ambiguous)
'''
"""
block:
proc foo(x: int | float): float = result = 1.0
let
bar = foo
baz = bar
block:
proc foo(x: int | float): float = result = 1.0
let
bar = foo[int]
baz = bar
block:
proc foo(x: int | float, y: int or string): float = result = 1.0
let
bar = foo[int]
baz = bar