fixes #2266
This commit is contained in:
parent
1681800d3c
commit
0d804c2052
4 changed files with 17 additions and 2 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# The Nim Compiler
|
# The Nim Compiler
|
||||||
# (c) Copyright 2013 Andreas Rumpf
|
# (c) Copyright 2015 Andreas Rumpf
|
||||||
#
|
#
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
|
|
|
||||||
|
|
@ -1537,7 +1537,9 @@ proc matchesAux(c: PContext, n, nOrig: PNode,
|
||||||
copyTree(n.sons[a]), m, c))
|
copyTree(n.sons[a]), m, c))
|
||||||
else:
|
else:
|
||||||
addSon(m.call, copyTree(n.sons[a]))
|
addSon(m.call, copyTree(n.sons[a]))
|
||||||
elif formal != nil:
|
elif formal != nil and formal.typ.kind == tyVarargs:
|
||||||
|
# beware of the side-effects in 'prepareOperand'! So only do it for
|
||||||
|
# varags matching. See tests/metatype/tstatic_overloading.
|
||||||
m.baseTypeMatch = false
|
m.baseTypeMatch = false
|
||||||
n.sons[a] = prepareOperand(c, formal.typ, n.sons[a])
|
n.sons[a] = prepareOperand(c, formal.typ, n.sons[a])
|
||||||
var arg = paramTypesMatch(m, formal.typ, n.sons[a].typ,
|
var arg = paramTypesMatch(m, formal.typ, n.sons[a].typ,
|
||||||
|
|
|
||||||
|
|
@ -919,6 +919,9 @@ proc sameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
|
||||||
result = sameFlags(a, b)
|
result = sameFlags(a, b)
|
||||||
of tyStatic, tyFromExpr:
|
of tyStatic, tyFromExpr:
|
||||||
result = exprStructuralEquivalent(a.n, b.n) and sameFlags(a, b)
|
result = exprStructuralEquivalent(a.n, b.n) and sameFlags(a, b)
|
||||||
|
if result and a.len == b.len and a.len == 1:
|
||||||
|
cycleCheck()
|
||||||
|
result = sameTypeAux(a.sons[0], b.sons[0], c)
|
||||||
of tyObject:
|
of tyObject:
|
||||||
ifFastObjectTypeCheckFailed(a, b):
|
ifFastObjectTypeCheckFailed(a, b):
|
||||||
cycleCheck()
|
cycleCheck()
|
||||||
|
|
|
||||||
10
tests/metatype/tstatic_overloading.nim
Normal file
10
tests/metatype/tstatic_overloading.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
# bug #2266
|
||||||
|
|
||||||
|
import macros
|
||||||
|
|
||||||
|
proc impl(op: static[int]) = echo "impl 1 called"
|
||||||
|
proc impl(op: static[int], init: int) = echo "impl 2 called"
|
||||||
|
|
||||||
|
macro wrapper2: stmt = newCall(bindSym"impl", newLit(0), newLit(0))
|
||||||
|
|
||||||
|
wrapper2() # Code generation for this fails.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue