-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Function for getting source location inside string macros #9577
Comments
Do we really need a special case here, or would this be handled by fixing #1334? |
Possibly, though it doesn't quite seem to be the same thing. The goal here, is e.g. to be able to report syntax errors for embedded DSLs with accurate line information. |
How about adding an implicit first argument to every macro call where we pass a LineNumberNode representing the invocation site? That would allow IMHO a cleaner fix for this issue than #9579, would allow cleaner |
Yes please |
What do we call it? |
Effectively, transform every macro from and change the parser so that |
Useful error reporting is a huge issue with macros, not sure if the hammer is really that large. |
Instinctively, this feels like a horrible band-aid, but I haven't come up with a practical downside yet (or better alternative -- my last idea was worse). So I'm hoping someone shoots it down and saves me an ~evening... If not, I'll give it a try. |
rather than modifying every macro ever written to accommodate a new first argument, would it be practical to have a special functions (only callable from a macro), that returns these values? |
Yikes, no. The additional argument would be added automatically in parsing and lowering, so it should be totally transparent to the user. Still might be a bad idea, but not that drastic.
I was wondering about this. How does that special function know where the macro was invoked? The line information needs to be stored somewhere that is accessible at expansion time. The only idea I've come up with so far is:
|
was this fixed now that |
@JeffBezanson any chance this could be bumped to a 0.5 target? #16335 seems to provide everything necessary at the AST level, but AFAICT we would still need a way to access that info from inside of macro-functions. |
For error reporting purposes, it would be convenient to expose line/column information to
_str
macros. This could either be done by passing them extra arguments in addition to the body of the string (in particular file/line/column of the start of the string) or adding a function that returns this information if inside a string macro.The text was updated successfully, but these errors were encountered: