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

wrong Error: cannot generate VM code depending on unrelated code #12732

Closed
timotheecour opened this issue Nov 25, 2019 · 1 comment · Fixed by #24119
Closed

wrong Error: cannot generate VM code depending on unrelated code #12732

timotheecour opened this issue Nov 25, 2019 · 1 comment · Fixed by #24119
Labels

Comments

@timotheecour
Copy link
Member

timotheecour commented Nov 25, 2019

very strange bug: we get a CT error Error: cannot generate VM code for valid code, and the CT error disappears when commenting out or making private an unrelated constant (or when using currentPkgDir2() instead of currentPkgDir2)

D20191124T182358

Example

nim c t0796.nim

t0796.nim:

import t0796b
const s0 = currentPkgDir2

t0796b.nim:

import std/macros
const getPrivate3_tmp* = 0
const foobar1* = 0 # comment this or make private and it'll compile fine
macro foobar4*(): untyped =
  newLit "abc"
template currentPkgDir2*: string = foobar4()
macro currentPkgDir2*(dir: string): untyped =
  newLit "abc2"

Current Output

t0796.nim(22, 12) Error: cannot generate VM code for currentPkgDir2

Expected Output

should compile

Additional Information

fails on all versions of nim, including recent devel f22d3c7

@timotheecour timotheecour changed the title Error: cannot generate VM code depending on unrelated code wrong Error: cannot generate VM code depending on unrelated code Nov 25, 2019
@mratsim mratsim added Macros VM see also `const` label labels Nov 25, 2019
@metagn
Copy link
Collaborator

metagn commented Aug 29, 2024

Now gives

t0796.nim(2, 12) Error: ambiguous identifier: 'currentPkgDir2' -- use one of the following:
  t0796b.currentPkgDir2: template (): string
  t0796b.currentPkgDir2: macro (dir: string): untyped{.noSideEffect, gcsafe.}

Is this fine?

Araq pushed a commit that referenced this issue Aug 30, 2024
closes #1969, closes #7547, closes #7737, closes #11838, closes #12283,
closes #12714, closes #12720, closes #14053, closes #16118, closes
#19670, closes #22645

I was going to wait on these but regression tests even for recent PRs
are turning out to be important in wide reaching PRs like #24010.

The other issues with the working label felt either finnicky (#7385,
#9156, #12732, #15247), excessive to test (#12405, #12424, #17527), or I
just don't know what fixed them/what the issue was (#16128: the PR link
gives a server error by Github, #12457, #12487).
metagn added a commit to metagn/Nim that referenced this issue Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants