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

Bug with ref type + fieldPairs + hasCustomPragma #12523

Closed
GULPF opened this issue Oct 26, 2019 · 0 comments · Fixed by #15085
Closed

Bug with ref type + fieldPairs + hasCustomPragma #12523

GULPF opened this issue Oct 26, 2019 · 0 comments · Fixed by #15085
Labels

Comments

@GULPF
Copy link
Member

GULPF commented Oct 26, 2019

The result of using fieldPairs + hasCustomPragma on a dereferenced ref value gives different results depending on if the ref type is declared directly or with a separate object type.

Example

import macros

template customPragma {.pragma.}

type
  RefType = ref object
    field {.customPragma.}: int

  ObjType = object
    field {.customPragma.}: int
  RefType2 = ref ObjType

block:
  let x = RefType()
  for fieldName, fieldSym in fieldPairs(x[]):
    echo hasCustomPragma(fieldSym, customPragma)

block:
  let x = RefType2()
  for fieldName, fieldSym in fieldPairs(x[]):
    echo hasCustomPragma(fieldSym, customPragma)

Current Output

false
true

Expected Output

true
true

Additional Information

Tested with latest devel.

@ghost ghost added the Macros label Jul 27, 2020
Clyybber pushed a commit that referenced this issue Jul 27, 2020
* Add a test-case for #12576

* Add a test-case for #12523
mildred pushed a commit to mildred/Nim that referenced this issue Jan 11, 2021
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.

1 participant