diff --git a/compiler/semmacrosanity.nim b/compiler/semmacrosanity.nim index f246e38fb2..cba6b4a46a 100644 --- a/compiler/semmacrosanity.nim +++ b/compiler/semmacrosanity.nim @@ -146,7 +146,12 @@ proc annotateType*(n: PNode, t: PType; conf: ConfigRef) = of nkCurly: if x.kind in {tySet}: n.typ() = t - for m in n: annotateType(m, x.elemType, conf) + for m in n: + if m.kind == nkRange: + annotateType(m[0], x.elemType, conf) + annotateType(m[1], x.elemType, conf) + else: + annotateType(m, x.elemType, conf) else: globalError(conf, n.info, "{} must have the set type") of nkFloatLit..nkFloat128Lit: diff --git a/tests/vm/tsetrange.nim b/tests/vm/tsetrange.nim new file mode 100644 index 0000000000..a0b8ce9c4a --- /dev/null +++ b/tests/vm/tsetrange.nim @@ -0,0 +1,17 @@ +# issue #24736 + +import std/setutils + +type CcsCatType = enum cctNone, cctHeader, cctIndex, cctSetup, cctUnk1, cctStream + +block: # original issue + const CCS_CAT_TYPES = fullSet(CcsCatType) + proc test(t: int): bool = t.CcsCatType in CCS_CAT_TYPES + discard test(5) + +block: # minimized + func foo(): set[CcsCatType] = + {cctNone..cctHeader} + const CCS_CAT_TYPES = foo() + proc test(t: int): bool = t.CcsCatType in CCS_CAT_TYPES + discard test(5)