Created
February 2, 2013 20:02
-
-
Save gradha/4699026 to your computer and use it in GitHub Desktop.
weird.nim(12, 9) Error: undeclared field: 'PK_INT'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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