-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Can't attach a pragma to a cased field. #14511
Comments
It's a known bug #11526 |
While that seems to cover hasCustomPragma being problematic, it doesn't seem to address this specific issue. |
@kayabaNerve it does though, I've been using parts of the code from that PR in my JSON.to fork to support field annotations - https://github.com/Yardanico/telenim/blob/master/src/telenim/json_custom.nim (especially https://github.com/Yardanico/telenim/blob/master/src/telenim/json_custom.nim#L194) |
The main trick there is that you have to do "yourSym.owner.getImpl()[2]" where yourSym is a symbol of a field of the object you want to get pragma of. |
Got it; I read through the discussion, not the source. Thanks for pointing that out; should I close this issue? |
Thanks for the workaround. |
@kayabaNerve not sure, probably you should keep it open unless that PR is merged :) |
Sure. Thanks again for linking the relevant PR and a workaround. |
Sorry, was browsing this issue on my phone and clicked the wrong button. |
Signed-off-by: Dankr4d <dude569@freenet.de>
Signed-off-by: Dankr4d <dude569@freenet.de>
Signed-off-by: Dankr4d <dude569@freenet.de>
Signed-off-by: Dankr4d <dude569@freenet.de>
* fixes #14511 [backport:1.4] Signed-off-by: Dankr4d <dude569@freenet.de> * Replaced fix with code from alaviss, for better readability, with small changes. Signed-off-by: Dankr4d <dude569@freenet.de> * - Specified output in test. Signed-off-by: Dankr4d <dude569@freenet.de> * Replaced case in nnkRecCase with a simpler version, which just adds the last son. Signed-off-by: Dankr4d <dude569@freenet.de> * Update tests/macros/t14511.nim * Update tests/macros/t14511.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
* fixes #14511 [backport:1.4] Signed-off-by: Dankr4d <dude569@freenet.de> * Replaced fix with code from alaviss, for better readability, with small changes. Signed-off-by: Dankr4d <dude569@freenet.de> * - Specified output in test. Signed-off-by: Dankr4d <dude569@freenet.de> * Replaced case in nnkRecCase with a simpler version, which just adds the last son. Signed-off-by: Dankr4d <dude569@freenet.de> * Update tests/macros/t14511.nim * Update tests/macros/t14511.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de> (cherry picked from commit c70e404)
* fixes nim-lang#14511 [backport:1.4] Signed-off-by: Dankr4d <dude569@freenet.de> * Replaced fix with code from alaviss, for better readability, with small changes. Signed-off-by: Dankr4d <dude569@freenet.de> * - Specified output in test. Signed-off-by: Dankr4d <dude569@freenet.de> * Replaced case in nnkRecCase with a simpler version, which just adds the last son. Signed-off-by: Dankr4d <dude569@freenet.de> * Update tests/macros/t14511.nim * Update tests/macros/t14511.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Attaching a pragma to a field used in a case within an object has no effect on the AST.
Example
Current Output
Expected Output
Additional Information
I did also try
X.y.hasCustomPragma(myPragma)
; that compiles, yet returns false.The text was updated successfully, but these errors were encountered: