diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index d8e90a5896..b9b1d0f99b 100755 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -663,6 +663,9 @@ proc builtinFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode = elif efAllowType notin flags: GlobalError(n.sons[0].info, errATypeHasNoValue) return + # reset to prevent 'nil' bug: see "tests/reject/tenumitems.nim": + ty = n.sons[0].Typ + ty = skipTypes(ty, {tyGenericInst, tyVar, tyPtr, tyRef}) var check: PNode = nil if ty.kind == tyObject: diff --git a/tests/reject/tenumitems.nim b/tests/reject/tenumitems.nim new file mode 100644 index 0000000000..a0497fd59f --- /dev/null +++ b/tests/reject/tenumitems.nim @@ -0,0 +1,9 @@ +discard """ + line: 7 + errormsg: "a type has no value" +""" + +type a = enum b,c,d +a.items() + +