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

macros.error, macros.warning, macros.hint easily conflict with routines with the same name #24249

Open
metagn opened this issue Oct 7, 2024 · 0 comments

Comments

@metagn
Copy link
Collaborator

metagn commented Oct 7, 2024

Originally encountered with an error here.

The routines named error, warning and hint in macros all take a single string argument and an optional NimNode argument for the line info, and return void. This means that calls like error("abc") will match the overload in macros.

But this is a feasible signature for procs in user code, especially logging libraries (like chronicles, which happens to work around it by requiring the string also be static). If macros is imported, calling these procs can easily give overload ambiguity errors. But the macros overloads are more specialized, they are only for compile time errors in macros.

To fix this, we can rename the overloads in macros to something like macroError, compileTimeError etc. (not sure which name is best, would appreciate suggestions), then deprecate the old symbols/remove them with a define. Alternatively we can also require the NimNode argument for the line info be provided explicitly, but this could still conflict with procs that accept values of any type and stringify them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant