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

quote do gives: a case selecting discriminator error with object variants #12

Open
timotheecour opened this issue Jun 20, 2019 · 1 comment

Comments

@timotheecour
Copy link
Owner

timotheecour commented Jun 20, 2019

#[
D20190620T000734
KEY BUG discriminator CT quote do

Error: a case selecting discriminator 'kind' with value 'k2' appears in the object construction, but the field(s) 'regs' are in conflict with this value.
    return @[Foo(kind: k1), Foo(kind: k2)]
]#

type Kind = enum k1, k2

type Foo = ref object
  case kind: Kind
  of k1:
    regs: string
  of k2:
    discard

import std/[macros]

proc fun(): auto =
  return @[Foo(kind: k1), Foo(kind: k2)]

macro parsefGen*(): untyped =
  let matchers = fun()
  result = newStmtList()

  template bar() =
    const a4 = fun()
  let n = getAst bar() # ok

  result.add quote do:
    const a1 = `matchers` # BUG
    # const a2 = fun() # ok

proc main() =
  parsefGen()
main()
@timotheecour
Copy link
Owner Author

check whether this would be fixed by macros.genAst nim-lang#11722

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

1 participant