Skip to content

Commit

Permalink
fixes nim-lang#12885 [backport] (nim-lang#12895)
Browse files Browse the repository at this point in the history
(cherry picked from commit 347a046)
  • Loading branch information
Araq authored and narimiran committed Dec 16, 2019
1 parent 261592d commit 7c4bc63
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions compiler/semtempl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ proc addLocalDecl(c: var TemplCtx, n: var PNode, k: TSymKind) =

proc semTemplSymbol(c: PContext, n: PNode, s: PSym; isField: bool): PNode =
incl(s.flags, sfUsed)
# bug #12885; ideally sem'checking is performed again afterwards marking
# the symbol as used properly, but the nfSem mechanism currently prevents
# that from happening, so we mark the module as used here already:
markOwnerModuleAsUsed(c, s)
# we do not call onUse here, as the identifier is not really
# resolved here. We will fixup the used identifiers later.
case s.kind
Expand Down
3 changes: 3 additions & 0 deletions tests/tools/second.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import tables

let dataEx* = {1: 2, 3: 4}.toTable
13 changes: 11 additions & 2 deletions tests/tools/tunused_imports.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@ discard """
cmd: '''nim c --hint[Processing]:off $file'''
nimout: '''
tunused_imports.nim(11, 10) Warning: BEGIN [User]
tunused_imports.nim(27, 10) Warning: END [User]
tunused_imports.nim(25, 8) Warning: imported and not used: 'strutils' [UnusedImport]
tunused_imports.nim(36, 10) Warning: END [User]
tunused_imports.nim(34, 8) Warning: imported and not used: 'strutils' [UnusedImport]
'''
action: "compile"
"""

{.warning: "BEGIN".}

# bug #12885

import tables, second

template test(key: int): untyped =
`[]`(dataEx, key)

echo test(1)

import net, dontmentionme

echo AF_UNIX
Expand Down

0 comments on commit 7c4bc63

Please sign in to comment.