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

code reordering feature gives warning when quoted method argument name matches a different method #20889

Open
Phytolizer opened this issue Nov 21, 2022 · 2 comments

Comments

@Phytolizer
Copy link
Contributor

Phytolizer commented Nov 21, 2022

What happened?

See this code.

# no warning if removed
{.experimental: "codeReordering".}

# no warning if `` quotes are removed or args are renamed
proc `bug`*(x: int, q: float, r: string): string =
  $(x + q.int) & r

# warning if it's named x, q, or r
# no warning if this isn't a proc/func
proc x* = discard

I am receiving a warning under the conditions mentioned in the comments:

/home/kyle/dev/dbTransfer/minimal.nim(5, 1) Warning: Circular dependency detected. codeReordering pragma may not be able to reorder some nodes properly:
line 5 depends on line 10: one declares "x" and the other uses it
line 10 depends on line 5: one declares a quoted identifier and the other has a body and comes after it

The more verbose output comes from the Nim compiler built with -d:nimDebugReorder (see #20888).

Nim Version

Nim Compiler Version 1.7.3 [Linux: amd64]
Compiled at 2022-11-21
Copyright (c) 2006-2022 by Andreas Rumpf

git hash: 370f1fd
active boot switches: -d:release

Current Standard Output Logs

No response

Expected Standard Output Logs

No response

Possible Solution

No response

Additional Information

No response

@Phytolizer
Copy link
Contributor Author

Phytolizer commented Nov 21, 2022

Some more details:

  • The argument in the first method that clashes with the other method name must be used within the body.
  • The warning disappears when the methods are swapped.
  • The number of arguments and their types do not matter; they can be the same, or completely different.

@khaledh
Copy link
Contributor

khaledh commented Jun 3, 2023

I ran into this issue, but in a different scenario:

{.experimental: "codeReordering".}

proc `a`() =
  b()

proc b() =
  discard

#  Warning: Circular dependency detected. `codeReordering` pragma may not be able to reorder some nodes properly

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

2 participants