mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-18 23:11:36 +00:00
fixes #2266
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#
|
||||
#
|
||||
# The Nim Compiler
|
||||
# (c) Copyright 2013 Andreas Rumpf
|
||||
# (c) Copyright 2015 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
|
||||
@@ -1537,7 +1537,9 @@ proc matchesAux(c: PContext, n, nOrig: PNode,
|
||||
copyTree(n.sons[a]), m, c))
|
||||
else:
|
||||
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
|
||||
n.sons[a] = prepareOperand(c, formal.typ, n.sons[a])
|
||||
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)
|
||||
of tyStatic, tyFromExpr:
|
||||
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:
|
||||
ifFastObjectTypeCheckFailed(a, b):
|
||||
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.
|
||||
Reference in New Issue
Block a user