Skip to content

Instantly share code, notes, and snippets.

@gradha
Created February 2, 2013 20:02
Show Gist options
  • Save gradha/4699026 to your computer and use it in GitHub Desktop.
Save gradha/4699026 to your computer and use it in GitHub Desktop.
weird.nim(12, 9) Error: undeclared field: 'PK_INT'
type
TNodeKind = enum PK_EMPTY, PK_INT, PK_STRING
TNode = object
case kind: TNodeKind
of PK_EMPTY: nil
of PK_INT: int_val: int
of PK_STRING: str_val: string
template new_node(kind: TNodeKind, expr): TNode {.immediate.} =
var result {.gensym.}: TNode
result.kind = kind
case kind:
of PK_EMPTY: nil
of PK_INT: result.int_val = expr
of PK_STRING: result.str_val = expr
result
when isMainModule:
var t1, t2 : TNode
t1.kind = PK_INT
t1.int_val = 3
t2.kind = PK_STRING
t2.str_val = "3"
let t3 = new_node(PK_INT, 3)
echo "Hey!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment