This commit is contained in:
Varriount 2014-10-23 21:49:38 -04:00 • committed by Clay Sweetser
commit a8a9dd6699
3 changed files with 17 additions and 1 deletions

View file

@ -11,7 +11,7 @@
# This is needed for proper handling of forward declarations. # This is needed for proper handling of forward declarations.
import import
ast, astalgo, msgs, semdata, types, trees ast, astalgo, msgs, semdata, types, trees, strutils
proc equalGenericParams(procA, procB: PNode): bool = proc equalGenericParams(procA, procB: PNode): bool =
if sonsLen(procA) != sonsLen(procB): return if sonsLen(procA) != sonsLen(procB): return
@ -68,11 +68,17 @@ proc searchForProcNew(c: PContext, scope: PScope, fn: PSym): PSym =
ExactConstraints, IgnoreCC} ExactConstraints, IgnoreCC}
var it: TIdentIter var it: TIdentIter
result = initIdentIter(it, scope.symbols, fn.name) result = initIdentIter(it, scope.symbols, fn.name)
while result != nil: while result != nil:
if result.kind in skProcKinds and sameType(result.typ, fn.typ, flags): if result.kind in skProcKinds and sameType(result.typ, fn.typ, flags):
case equalParams(result.typ.n, fn.typ.n) case equalParams(result.typ.n, fn.typ.n)
of paramsEqual: of paramsEqual:
if (sfExported notin result.flags) and (sfExported in fn.flags):
let message = ("public implementation '$1' has non-public " &
"forward declaration in $2") %
[getProcHeader(result), $result.info]
localError(fn.info, errGenerated, message)
return return
of paramsIncompatible: of paramsIncompatible:
localError(fn.info, errNotOverloadable, fn.name.s) localError(fn.info, errNotOverloadable, fn.name.s)

View file

@ -40,6 +40,7 @@ path="$lib/pure/unidecode"
@if nimbabel: @if nimbabel:
babelpath="$home/.babel/pkgs/" babelpath="$home/.babel/pkgs/"
nimblepath="$home/.nimble/pkgs/"
@end @end
@if release or quick: @if release or quick:

View file

@ -0,0 +1,9 @@
discard """
line: 8
errormsg: "public implementation 'tmismatchedvisibility.foo(a: int): int' has non-public forward declaration in tmismatchedvisibility.nim(6,5)"
"""
proc foo(a: int): int
proc foo*(a: int): int =
result = a + a