parent
ee29370f60
commit
aa1cdebdc2
2 changed files with 24 additions and 0 deletions
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue