mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
closes #5868
This commit is contained in:
@@ -5,6 +5,7 @@ Container
|
||||
TObj
|
||||
int
|
||||
111 111
|
||||
(id: @[1, 2, 3], name: @["Vas", "Pas", "NafNaf"], age: @[10, 16, 18])
|
||||
'''
|
||||
"""
|
||||
|
||||
@@ -107,3 +108,21 @@ let usedToFail: stringTest = "111"
|
||||
let working: string = "111"
|
||||
|
||||
echo usedToFail, " ", working
|
||||
|
||||
# bug #5868
|
||||
|
||||
type TaggedType[T; Key: static[string]] = T
|
||||
|
||||
proc setKey*[DT](dt: DT, key: static[string]): TaggedType[DT, key] =
|
||||
result = cast[type(result)](dt)
|
||||
|
||||
type Students = object
|
||||
id : seq[int]
|
||||
name : seq[string]
|
||||
age: seq[int]
|
||||
|
||||
let
|
||||
stud = Students(id : @[1,2,3], name : @["Vas", "Pas", "NafNaf"], age : @[10,16,18])
|
||||
stud2 = stud.setkey("id")
|
||||
|
||||
echo stud2
|
||||
|
||||
Reference in New Issue
Block a user