fixes #2159
Hints and warnings are only emitted for the main package that is compiled
This commit is contained in:
parent
b479c94721
commit
0b84ee167b
4 changed files with 18 additions and 1 deletions
|
|
@ -961,6 +961,9 @@ const
|
||||||
skMethod, skConverter}
|
skMethod, skConverter}
|
||||||
|
|
||||||
var ggDebug* {.deprecated.}: bool ## convenience switch for trying out things
|
var ggDebug* {.deprecated.}: bool ## convenience switch for trying out things
|
||||||
|
var
|
||||||
|
gMainPackageId*: int
|
||||||
|
gMainPackageNotes*: TNoteKinds
|
||||||
|
|
||||||
proc isCallExpr*(n: PNode): bool =
|
proc isCallExpr*(n: PNode): bool =
|
||||||
result = n.kind in nkCallKinds
|
result = n.kind in nkCallKinds
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,9 @@ proc compileModule*(fileIdx: int32, flags: TSymFlags): PSym =
|
||||||
#var rd = handleSymbolFile(result)
|
#var rd = handleSymbolFile(result)
|
||||||
var rd: PRodReader
|
var rd: PRodReader
|
||||||
result.flags = result.flags + flags
|
result.flags = result.flags + flags
|
||||||
|
if sfMainModule in result.flags:
|
||||||
|
gMainPackageId = result.owner.id
|
||||||
|
|
||||||
if gCmd in {cmdCompileToC, cmdCompileToCpp, cmdCheck, cmdIdeTools}:
|
if gCmd in {cmdCompileToC, cmdCompileToCpp, cmdCheck, cmdIdeTools}:
|
||||||
rd = handleSymbolFile(result)
|
rd = handleSymbolFile(result)
|
||||||
if result.id < 0:
|
if result.id < 0:
|
||||||
|
|
@ -183,6 +186,9 @@ proc importModule*(s: PSym, fileIdx: int32): PSym {.procvar.} =
|
||||||
if optCaasEnabled in gGlobalOptions: addDep(s, fileIdx)
|
if optCaasEnabled in gGlobalOptions: addDep(s, fileIdx)
|
||||||
if sfSystemModule in result.flags:
|
if sfSystemModule in result.flags:
|
||||||
localError(result.info, errAttemptToRedefine, result.name.s)
|
localError(result.info, errAttemptToRedefine, result.name.s)
|
||||||
|
# restore the notes for outer module:
|
||||||
|
gNotes = if s.owner.id == gMainPackageId: gMainPackageNotes
|
||||||
|
else: ForeignPackageNotes
|
||||||
|
|
||||||
proc includeModule*(s: PSym, fileIdx: int32): PNode {.procvar.} =
|
proc includeModule*(s: PSym, fileIdx: int32): PNode {.procvar.} =
|
||||||
result = syntaxes.parseFile(fileIdx)
|
result = syntaxes.parseFile(fileIdx)
|
||||||
|
|
|
||||||
|
|
@ -500,12 +500,14 @@ type
|
||||||
ESuggestDone* = object of Exception
|
ESuggestDone* = object of Exception
|
||||||
|
|
||||||
const
|
const
|
||||||
|
ForeignPackageNotes*: TNoteKinds = {hintProcessing, warnUnknownMagic,
|
||||||
|
hintQuitCalled}
|
||||||
NotesVerbosity*: array[0..3, TNoteKinds] = [
|
NotesVerbosity*: array[0..3, TNoteKinds] = [
|
||||||
{low(TNoteKind)..high(TNoteKind)} - {warnShadowIdent, warnUninit,
|
{low(TNoteKind)..high(TNoteKind)} - {warnShadowIdent, warnUninit,
|
||||||
warnProveField, warnProveIndex,
|
warnProveField, warnProveIndex,
|
||||||
warnGcUnsafe,
|
warnGcUnsafe,
|
||||||
hintSuccessX, hintPath, hintConf,
|
hintSuccessX, hintPath, hintConf,
|
||||||
hintProcessing,
|
hintProcessing, hintPattern,
|
||||||
hintDependency,
|
hintDependency,
|
||||||
hintExecuting, hintLinking,
|
hintExecuting, hintLinking,
|
||||||
hintCodeBegin, hintCodeEnd,
|
hintCodeBegin, hintCodeEnd,
|
||||||
|
|
|
||||||
|
|
@ -413,6 +413,12 @@ proc myOpen(module: PSym): PPassContext =
|
||||||
c.importTable.addSym magicsys.systemModule # import the "System" identifier
|
c.importTable.addSym magicsys.systemModule # import the "System" identifier
|
||||||
importAllSymbols(c, magicsys.systemModule)
|
importAllSymbols(c, magicsys.systemModule)
|
||||||
c.topLevelScope = openScope(c)
|
c.topLevelScope = openScope(c)
|
||||||
|
# don't be verbose unless the module belongs to the main package:
|
||||||
|
if module.owner.id == gMainPackageId:
|
||||||
|
gNotes = gMainPackageNotes
|
||||||
|
else:
|
||||||
|
if gMainPackageNotes == {}: gMainPackageNotes = gNotes
|
||||||
|
gNotes = ForeignPackageNotes
|
||||||
result = c
|
result = c
|
||||||
|
|
||||||
proc myOpenCached(module: PSym, rd: PRodReader): PPassContext =
|
proc myOpenCached(module: PSym, rd: PRodReader): PPassContext =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue