Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect unused import warning involving templates and tables #12885

Closed
Jjp137 opened this issue Dec 12, 2019 · 0 comments
Closed

Incorrect unused import warning involving templates and tables #12885

Jjp137 opened this issue Dec 12, 2019 · 0 comments

Comments

@Jjp137
Copy link
Contributor

Jjp137 commented Dec 12, 2019

The following example results in an unused import warning being incorrectly reported.

Example

Two small modules are involved in this example.

first.nim:

import tables, second

template test(key: int): int =
  data[key]

echo test(1)

second.nim:

import tables

let data* = {1: 2, 3: 4}.toTable

Build with nim c first.nim.

Current Output

Among the usual compiler output:

first.nim(1, 16) Warning: imported and not used: 'second' [UnusedImport]

Expected Output

Since data is used, that warning should not appear. Removing the import as the warning suggests causes the program to fail to compile.

Additional Information

The incorrect unused import warning does not appear if any one of these is true:

  • The template is a proc instead
  • The template's body is changed to data.len
  • The table was replaced with something simpler such as let x* = 5, and the template's body was changed to just x

Output of nim -v:

Nim Compiler Version 1.1.1 [Linux: amd64]
Compiled at 2019-12-12
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: 94289161f9dd00b2fc3070b08895a3b6c557ef44
active boot switches: -d:release

Also occurs with 1.0.4.

Araq added a commit that referenced this issue Dec 13, 2019
@Araq Araq closed this as completed in 347a046 Dec 13, 2019
narimiran pushed a commit to narimiran/Nim that referenced this issue Dec 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant