From 1d94d60c7b7d70fcf0de02097d2d8381d2d0a02d Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Thu, 8 Jan 2026 20:55:10 +0800 Subject: [PATCH] fixes #25419; lift magic types to typeclasses --- compiler/semstmts.nim | 7 +++++++ tests/types/tissues_types.nim | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index be9e409108..1cf24c9beb 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -1845,6 +1845,13 @@ proc typeSectionFinalPass(c: PContext, n: PNode) = let baseType = s.typ.safeSkipTypes(abstractPtrs) if baseType.kind in {tyObject, tyTuple} and not baseType.n.isNil: checkForMetaFields(c, baseType.n, hasError) + + if s.typ.kind in {tySet, tyArray, tySequence} and s.typ.elementType.kind == tyNone: + # magic generics are not filled but tyNone is added to its elements by default, + # we lift them to tyBuiltInTypeClass here + s.typ = newTypeS(tyBuiltInTypeClass, c, + newTypeS(s.typ.kind, c)) + if not hasError: checkConstructedType(c.config, s.info, s.typ) #instAllTypeBoundOp(c, n.info) diff --git a/tests/types/tissues_types.nim b/tests/types/tissues_types.nim index 6bb1258f4d..0421de2125 100644 --- a/tests/types/tissues_types.nim +++ b/tests/types/tissues_types.nim @@ -116,3 +116,13 @@ block: s(something) s(otherthing, something) s(something, otherthing) + +block: + type + Test = set + Test2 = seq + Test3 = array + + doAssert set is Test + doAssert seq is Test2 + doAssert array is Test3