diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index e904579283..4c2d84c29f 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -223,7 +223,7 @@ proc semSet(c: PContext, n: PNode, prev: PType): PType = if base.kind in {tyGenericInst, tyAlias, tySink}: base = skipModifier(base) if base.kind notin {tyGenericParam, tyGenericInvocation}: if base.kind == tyForward: - c.forwardTypeUpdates.add (getCurrOwner(c), base, n[1]) + c.forwardTypeUpdates.add (getCurrOwner(c), result, n) elif not isOrdinalType(base, allowEnumWithHoles = true): localError(c.config, n.info, errOrdinalTypeExpected % typeToString(base, preferDesc)) elif lengthOrd(c.config, base) > MaxSetElements: diff --git a/tests/types/tillegalset.nim b/tests/types/tillegalset.nim new file mode 100644 index 0000000000..e4f60da444 --- /dev/null +++ b/tests/types/tillegalset.nim @@ -0,0 +1,7 @@ +discard """ + errormsg: "set is too large; use `std/sets` for ordinal types with more than 2^16 elements" +""" + +type + Foo = set[Bar] + Bar = int32 diff --git a/tests/types/tillegalset2.nim b/tests/types/tillegalset2.nim new file mode 100644 index 0000000000..737e7a5892 --- /dev/null +++ b/tests/types/tillegalset2.nim @@ -0,0 +1,8 @@ +discard """ + errormsg: "set is too large; use `std/sets` for ordinal types with more than 2^16 elements" +""" + +type + Foo = int32 + Bar = set[Baz] + Baz = Foo