mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-10 15:04:59 +00:00
@@ -1809,6 +1809,10 @@ proc userConvMatch(c: PContext, m: var TCandidate, f, a: PType,
|
||||
# see tests/tgenericconverter:
|
||||
let srca = typeRel(m, src, a)
|
||||
if srca notin {isEqual, isGeneric, isSubtype}: continue
|
||||
|
||||
let constraint = c.converters[i].typ.n[1].sym.constraint
|
||||
if not constraint.isNil and not matchNodeKinds(constraint, arg):
|
||||
continue
|
||||
|
||||
let destIsGeneric = containsGenericType(dest)
|
||||
if destIsGeneric:
|
||||
|
||||
20
tests/converter/tconverter_with_constraint.nim
Normal file
20
tests/converter/tconverter_with_constraint.nim
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
discard """
|
||||
file: "tconverter_with_constraint.nim"
|
||||
line: 20
|
||||
errormsg: "type mismatch: got <int>"
|
||||
"""
|
||||
|
||||
type
|
||||
MyType = distinct int
|
||||
|
||||
converter to_mytype(m: int{lit}): MyType =
|
||||
m.MyType
|
||||
|
||||
proc myproc(m: MyType) =
|
||||
echo m.int, ".MyType"
|
||||
|
||||
myproc(1) # call by literal is ok
|
||||
|
||||
var x: int = 12
|
||||
myproc(x) # should fail
|
||||
Reference in New Issue
Block a user