mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-25 12:25:08 +00:00
fixes #6393
This commit is contained in:
@@ -66,12 +66,10 @@ proc searchForProcOld*(c: PContext, scope: PScope, fn: PSym): PSym =
|
||||
proc searchForProcNew(c: PContext, scope: PScope, fn: PSym): PSym =
|
||||
const flags = {ExactGenericParams, ExactTypeDescValues,
|
||||
ExactConstraints, IgnoreCC}
|
||||
|
||||
var it: TIdentIter
|
||||
|
||||
result = initIdentIter(it, scope.symbols, fn.name)
|
||||
while result != nil:
|
||||
if result.kind == fn.kind and sameType(result.typ, fn.typ, flags):
|
||||
if result.kind == fn.kind: #and sameType(result.typ, fn.typ, flags):
|
||||
case equalParams(result.typ.n, fn.typ.n)
|
||||
of paramsEqual:
|
||||
if (sfExported notin result.flags) and (sfExported in fn.flags):
|
||||
@@ -85,11 +83,8 @@ proc searchForProcNew(c: PContext, scope: PScope, fn: PSym): PSym =
|
||||
return
|
||||
of paramsNotEqual:
|
||||
discard
|
||||
|
||||
result = nextIdentIter(it, scope.symbols)
|
||||
|
||||
return nil
|
||||
|
||||
proc searchForProc*(c: PContext, scope: PScope, fn: PSym): PSym =
|
||||
result = searchForProcNew(c, scope, fn)
|
||||
when false:
|
||||
|
||||
@@ -777,8 +777,8 @@ proc equalParams(a, b: PNode): TParamsEquality =
|
||||
return paramsNotEqual # paramsIncompatible;
|
||||
# continue traversal! If not equal, we can return immediately; else
|
||||
# it stays incompatible
|
||||
if not sameTypeOrNil(a.sons[0].typ, b.sons[0].typ, {ExactTypeDescValues}):
|
||||
if (a.sons[0].typ == nil) or (b.sons[0].typ == nil):
|
||||
if not sameTypeOrNil(a.typ, b.typ, {ExactTypeDescValues}):
|
||||
if (a.typ == nil) or (b.typ == nil):
|
||||
result = paramsNotEqual # one proc has a result, the other not is OK
|
||||
else:
|
||||
result = paramsIncompatible # overloading by different
|
||||
|
||||
9
tests/errmsgs/tcant_overload_by_return_type.nim
Normal file
9
tests/errmsgs/tcant_overload_by_return_type.nim
Normal file
@@ -0,0 +1,9 @@
|
||||
discard """
|
||||
errormsg: "overloaded 'x' leads to ambiguous calls"
|
||||
line: 9
|
||||
"""
|
||||
|
||||
# bug #6393
|
||||
|
||||
proc x(): int = 7
|
||||
proc x(): string = "strange"
|
||||
Reference in New Issue
Block a user