mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 12:07:51 +00:00
fixes #5405
This commit is contained in:
@@ -168,16 +168,6 @@ proc commonType*(x, y: PType): PType =
|
||||
proc newSymS(kind: TSymKind, n: PNode, c: PContext): PSym =
|
||||
result = newSym(kind, considerQuotedIdent(n), getCurrOwner(), n.info)
|
||||
|
||||
proc getGenSym(c: PContext; s: PSym): PSym =
|
||||
var it = c.p
|
||||
while it != nil:
|
||||
result = get(it, s)
|
||||
if result != nil:
|
||||
#echo "got from table ", result.name.s, " ", result.info
|
||||
return result
|
||||
it = it.next
|
||||
result = s
|
||||
|
||||
proc newSymG*(kind: TSymKind, n: PNode, c: PContext): PSym =
|
||||
proc `$`(kind: TSymKind): string = substr(system.`$`(kind), 2).toLowerAscii
|
||||
|
||||
|
||||
@@ -157,6 +157,26 @@ proc get*(p: PProcCon; key: PSym): PSym =
|
||||
if p.mapping.data == nil: return nil
|
||||
result = PSym(p.mapping.idTableGet(key))
|
||||
|
||||
proc getGenSym*(c: PContext; s: PSym): PSym =
|
||||
if sfGenSym notin s.flags: return s
|
||||
var it = c.p
|
||||
while it != nil:
|
||||
result = get(it, s)
|
||||
if result != nil:
|
||||
#echo "got from table ", result.name.s, " ", result.info
|
||||
return result
|
||||
it = it.next
|
||||
result = s
|
||||
|
||||
proc considerGenSyms*(c: PContext; n: PNode) =
|
||||
if n.kind == nkSym:
|
||||
let s = getGenSym(c, n.sym)
|
||||
if n.sym != s:
|
||||
n.sym = s
|
||||
else:
|
||||
for i in 0..<n.safeLen:
|
||||
considerGenSyms(c, n.sons[i])
|
||||
|
||||
proc newOptionEntry*(): POptionEntry =
|
||||
new(result)
|
||||
result.options = gOptions
|
||||
|
||||
@@ -1583,12 +1583,14 @@ proc prepareOperand(c: PContext; formal: PType; a: PNode): PNode =
|
||||
result = c.semOperand(c, a, flags)
|
||||
else:
|
||||
result = a
|
||||
considerGenSyms(c, result)
|
||||
|
||||
proc prepareOperand(c: PContext; a: PNode): PNode =
|
||||
if a.typ.isNil:
|
||||
result = c.semOperand(c, a, {efDetermineType})
|
||||
else:
|
||||
result = a
|
||||
considerGenSyms(c, result)
|
||||
|
||||
proc prepareNamedParam(a: PNode) =
|
||||
if a.sons[0].kind != nkIdent:
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
discard """
|
||||
output: '''[0.0, 0.0, 0.0]
|
||||
|
||||
[0.0, 0.0, 0.0, 0.0]
|
||||
|
||||
5050'''
|
||||
"""
|
||||
|
||||
template mathPerComponent(op: untyped): untyped =
|
||||
proc op*[N,T](v,u: array[N,T]): array[N,T] {.inline.} =
|
||||
@@ -32,3 +39,11 @@ proc main =
|
||||
discard zipWithIndex(@[true, false])
|
||||
|
||||
main()
|
||||
|
||||
# bug #5405
|
||||
|
||||
proc main2() =
|
||||
let s = toSeq(1..100).foldL(a + b)
|
||||
echo s
|
||||
|
||||
main2()
|
||||
|
||||
Reference in New Issue
Block a user