parent
5df7d72afe
commit
931ee0ca82
2 changed files with 37 additions and 1 deletions
|
|
@ -260,12 +260,32 @@ proc replaceTypeVarsS(cl: var TReplTypeVars, s: PSym): PSym =
|
||||||
|
|
||||||
#result = PSym(idTableGet(cl.symMap, s))
|
#result = PSym(idTableGet(cl.symMap, s))
|
||||||
#if result == nil:
|
#if result == nil:
|
||||||
|
#[
|
||||||
|
|
||||||
|
We cannot naively check for symbol recursions, because otherwise
|
||||||
|
object types A, B whould share their fields!
|
||||||
|
|
||||||
|
import tables
|
||||||
|
|
||||||
|
type
|
||||||
|
Table[S, T] = object
|
||||||
|
x: S
|
||||||
|
y: T
|
||||||
|
|
||||||
|
G[T] = object
|
||||||
|
inodes: Table[int, T] # A
|
||||||
|
rnodes: Table[T, int] # B
|
||||||
|
|
||||||
|
var g: G[string]
|
||||||
|
|
||||||
|
]#
|
||||||
result = copySym(s)
|
result = copySym(s)
|
||||||
incl(result.flags, sfFromGeneric)
|
incl(result.flags, sfFromGeneric)
|
||||||
#idTablePut(cl.symMap, s, result)
|
#idTablePut(cl.symMap, s, result)
|
||||||
result.owner = s.owner
|
result.owner = s.owner
|
||||||
result.typ = replaceTypeVarsT(cl, s.typ)
|
result.typ = replaceTypeVarsT(cl, s.typ)
|
||||||
result.ast = replaceTypeVarsN(cl, s.ast)
|
if result.kind != skType:
|
||||||
|
result.ast = replaceTypeVarsN(cl, s.ast)
|
||||||
|
|
||||||
proc lookupTypeVar(cl: var TReplTypeVars, t: PType): PType =
|
proc lookupTypeVar(cl: var TReplTypeVars, t: PType): PType =
|
||||||
result = cl.typeMap.lookup(t)
|
result = cl.typeMap.lookup(t)
|
||||||
|
|
@ -685,6 +705,10 @@ proc recomputeFieldPositions*(t: PType; obj: PNode; currPosition: var int) =
|
||||||
|
|
||||||
proc generateTypeInstance*(p: PContext, pt: TIdTable, info: TLineInfo,
|
proc generateTypeInstance*(p: PContext, pt: TIdTable, info: TLineInfo,
|
||||||
t: PType): PType =
|
t: PType): PType =
|
||||||
|
# Given `t` like Foo[T]
|
||||||
|
# pt: Table with type mappings: T -> int
|
||||||
|
# Desired result: Foo[int]
|
||||||
|
# proc (x: T = 0); T -> int ----> proc (x: int = 0)
|
||||||
var typeMap = initLayeredTypeMap(pt)
|
var typeMap = initLayeredTypeMap(pt)
|
||||||
var cl = initTypeVars(p, addr(typeMap), info, nil)
|
var cl = initTypeVars(p, addr(typeMap), info, nil)
|
||||||
pushInfoContext(p.config, info)
|
pushInfoContext(p.config, info)
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ output: '''
|
||||||
16
|
16
|
||||||
b is 2 times a
|
b is 2 times a
|
||||||
17
|
17
|
||||||
|
['\x00', '\x00', '\x00', '\x00']
|
||||||
'''
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -154,3 +155,14 @@ block:
|
||||||
|
|
||||||
const uk = MicroKernel(a: 5.5, b: 1)
|
const uk = MicroKernel(a: 5.5, b: 1)
|
||||||
tFunc[uk]()
|
tFunc[uk]()
|
||||||
|
|
||||||
|
|
||||||
|
# bug #7258
|
||||||
|
type
|
||||||
|
StringValue*[LEN: static[Natural]] = array[LEN+Natural(2),char]
|
||||||
|
StringValue16* = StringValue[2]
|
||||||
|
|
||||||
|
var
|
||||||
|
s: StringValue16
|
||||||
|
|
||||||
|
echo s
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue